title: how to split dart class in flutter?
body: <p>I did the following test, but it doesn't work:</p>
  
  <pre><code>//main.dart
  class Test
  {
    static const   a = 10;
    final b = 20;
    final c = a+1;
  
  }
  
  //part.dart
  part of 'main.dart';
  class Test
  {
    final d = a +1;   //&lt;---undefined name 'a'
  } 
  </code></pre>
  
  <p>I would like to split the class in <a href="https://flutter.io/get-started/codelab/" rel="noreferrer">flutter tutorial</a> into multiple files. For example: _buildSuggestions in a separate file, _buildRow in a separate file, etc.</p>
  
  <p><strong>update:</strong></p>
  
  <p>my solution:</p>
  
  <p>before:</p>
  
  <pre><code>//main.dart
  class RandomWordsState extends State&lt;RandomWords&gt; {
  {
      final _var1;
      final _var2;
      @override
      Widget build(BuildContext context) {
        ...
        body: _buildList(),
      );
  
      Widget _buildList() { ... }
      Widget _buildRow() { ... }
  }
  </code></pre>
  
  <p>after:</p>
  
  <pre><code>//main.dart
  import 'buildlist.dart';
  class RandomWordsState extends State&lt;RandomWords&gt; {
  {
      final var1;
      final var2;
      @override
      Widget build(BuildContext context) {
        ...
        body: buildList(this),
      );
  
  }
  
  //buildlist.dart
  import 'main.dart';
  
    Widget buildList(RandomWordsState obj) {
       ... obj.var1 ...
    }
  </code></pre>