title: The following ArgumentError was thrown building Home(dirty, state: _HomeState#3752d): Invalid argument(s)
body: <p><a href="https://i.stack.imgur.com/KcVXC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KcVXC.png" alt="enter image description here"></a>I am getting dirty state exception when redirecting on a new page after login. On this home page I am getting info from preferences. </p>
  
  <pre><code>class Home extends StatefulWidget{
    @override
    State&lt;StatefulWidget&gt; createState() =&gt; new _HomeState();
  }
  
  class _HomeState extends State&lt;Home&gt; {
    Drawer drawer = new Drawer();
  
    String strName, strEmail, strImageURL;
    int userId;
    Image imgProfile;
  
    @override
    void initState() {
      super.initState();
      _loadSharedPref();
    }
  
    //Loading Shared value on start
    _loadSharedPref() async {
      print('In Shared Profile');
      try{
        SharedPreferences prefs = await SharedPreferences.getInstance();
        strName = prefs.getString('name');
        print('Shared Profile Name '+strName);
        setState(() {
          strName = prefs.getString('name');
          userId = prefs.getInt('userId');
          strEmail = prefs.getString('email');
          strImageURL = prefs.getString('avatar');
          imgProfile = Image.network(Config.PROFILE_PIC+strImageURL);
          print('Image URL ---- '+Config.PROFILE_PIC+strImageURL);
        });
      }catch(exception){
        print('SharedProfile '+exception);
      }
  
    }
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        home: new Scaffold(
          backgroundColor: whiteColor,
          drawer: sideDrawer(),
          appBar: new AppBar(
            title: new Text('Test Page'),
          ),
        ),
      );
    }
  
    //Profile Details
    Widget profileDetail() {
      return new DrawerHeader(
          child: new Column(
            children: &lt;Widget&gt;[
              new CircleAvatar(
                radius: 40,
                backgroundColor : blueColor,
                backgroundImage: new NetworkImage(Config.PROFILE_PIC+strImageURL),
              ),
            ],
          )
      );
    }
  
    //Side Drawer
    Widget sideDrawer(){
      return new Drawer(
        child: new ListView(
          children: &lt;Widget&gt;[
            new Center(
              child: profileDetail(),
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('Requests'),
  //          onTap: () =&gt; _onListTileTap(context),
  
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('Reviews'),
  //            onTap: () =&gt; _onListTileTap(context),
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('Setting'),
  //            onTap: () =&gt; _onListTileTap(context),
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('Tip'),
  //            onTap: () =&gt; _onListTileTap(context),
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('Conditions'),
  //            onTap: () =&gt; _onListTileTap(context),
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('About Us'),
  //            onTap: () =&gt; _onListTileTap(context),
            ),
            new ListTile(
              leading: new Icon(Icons.lightbulb_outline),
              title: new Text('Log Out'),
  //            onTap: () =&gt; _onListTileTap(context),
            ),
          ],
        ),
      );
    }
  }
  </code></pre>
  
  <p>Cross-link <a href="https://github.com/flutter/flutter/issues/25428" rel="nofollow noreferrer">https://github.com/flutter/flutter/issues/25428</a></p>