title: Unable to initialize static member in Dart
body: <p>I have read similar questions </p>
  
  <ol>
  <li><a href="https://stackoverflow.com/questions/50145150/error-only-static-members-can-be-accessed-in-initializers-what-does-this-mean">Error: Only static members can be accessed in initializers what does this mean?</a></li>
  <li><a href="https://stackoverflow.com/questions/50682496/dart-only-static-members-can-accessed-in-initializers">Dart - Only static members can accessed in initializers</a></li>
  </ol>
  
  <p>But I am still unable to solve the problem.</p>
  
  <p>I am sending Ip object which has a Ip string from one screen to another.</p>
  
  <p>Here is Second screen's widget and state class in short.</p>
  
  <pre><code>class DrawingPage extends StatefulWidget {
    Ip ipObj;
  //  String ipObj;
    DrawingPage({Key key, @required this.ipObj});
    _DrawingPageState createState() =&gt; _DrawingPageState();
  }
  </code></pre>
  
  <pre><code>class _DrawingPageState extends State&lt;DrawingPage&gt; {
  
    final String ip = widget.ipObj.ip;     //Error at "widget": Only Static members can be accessed in initializers
  
  
  }
  </code></pre>
  
  <p>I have tried </p>
  
  <p>1.<a href="https://dart.dev/guides/language/language-tour#initializer-list" rel="nofollow noreferrer">Initializer's List</a>.</p>
  
  <p>2.Converting final to static member and then assigning ip value in initState does work.</p>
  
  <p>But the value is set when initState is invoked, but I want to set value before initState.</p>
  
  <p>How should I do it? </p>