title: How to pass object to StatefulWidget while Routing in Flutter?
body: <p>I have <strong>MyApp</strong> class which is responsible for loading application. I'm loading a Class <strong>HomeWidget</strong> as home in MyApp. </p>
  
  <pre><code>void main() =&gt; runApp(new myApp());
  class myApp extends StatelessWidget{
      @override
      Widget build(BuildContext context) {
             return new MaterialApp(
               title: 'My App',
               color: Colors.grey,
               home: new HomeWidget(),
               theme: new ThemeData(
                 primarySwatch: Colors.lightBlue,
               ),
               routes: &lt;String, WidgetBuilder&gt;{
                   "/ItemDetailWidget": (BuildContext context) =&gt; new MovieDetailsPage(),
      },
  );}}
  </code></pre>
  
  <p>HomeWidget contains - Header, ListView, BottomNavigation. </p>
  
  <p>When user taps particular item from ListView, I wanted to show new Widget/Page(<strong>ItemDetailWidget</strong>) which has all information about that particular item.</p>
  
  <p>So i created <strong>ItemDetailWidget</strong> which is stateful and it accepts one parameter which is of type Object <strong>MyModel</strong> suppose. I made it stateful for purpose. </p>
  
  <blockquote>
    <p>How should i add ItemDetailWidget into Routes as i'm passing
    parameter to it?</p>
  </blockquote>
  
  <p>I tried using </p>
  
  <pre><code>        "/ItemDetailWidget": (BuildContext context) =&gt; new ItemDetailWidget(),
  </code></pre>
  
  <p>However, It throwing error as "<strong>The Constructor return type dynamic that isn't of expected type widget</strong>"</p>
  
  <p>&amp; Also how can i pass MyModel object to ItemDetailWidget using Navigator syntax? I'm having onTap() function in ListView.</p>
  
  <p>Navigator.of(context).pushNamed('/widget1');</p>