title: Can´t pass null variable between two pages in flutter
body: <p>I´m trying to navigate between two pages. In second page I need a constructor so i need to declare the variable null in first page and initialize it in the second page.</p>
  
  <p>In <em>main.dart</em> (first page) i have similar to</p>
  
  <pre><code>PostDetailsPage.tag: (context) =&gt; PostDetailsPage(new List()),
  </code></pre>
  
  <p>In the second page (<em>PostDetailsPage</em>) i have this</p>
  
  <pre><code>final List&lt;charts.Series&gt; seriesList;
  final bool animate;
  
  PostDetailsPage(this.seriesList, {this.animate});
  </code></pre>
  
  <p>When i go to page two return</p>
  
  <blockquote>
    <p><em>&lt; List &lt; Series&lt; dynamic, dynamic > > is not a subtype of type &lt; List &lt; Series&lt; dynamic, String>></em></p>
  </blockquote>
  
  <p>So how can i solve? Initializate the value in first page and pass it? Initializate value as null in first page and pass it?</p>
  
  <p><strong>UPDATED</strong></p>
  
  <p>Main.dart class</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:fluttercrud/screens/login_page.dart';
  import 'package:fluttercrud/screens/home_page.dart';
  import 'package:fluttercrud/screens/partials/list_post.dart';
  import 'package:fluttercrud/screens/maps_page.dart';
  import 'package:fluttercrud/screens/post_details_page.dart';
  
  
  void main() =&gt; runApp(MyApp());
  
  
  class MyApp extends StatelessWidget {
    final routes = &lt;String, WidgetBuilder&gt;{
      LoginPage.tag: (context) =&gt; LoginPage(),
      HomePage.tag: (context) =&gt; HomePage(),
      ListPost.tag: (context) =&gt; ListPost(),
      MapsPage.tag: (context) =&gt; MapsPage(),
      PostDetailsPage.tag: (context) =&gt; PostDetailsPage(new List()),
    };
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'iGota',    
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch  : Colors.blue,
        ),
        home: LoginPage(),
        routes: routes,
      );
    }
  }
  </code></pre>
  
  <p>PostDetailsPage.dart class</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:charts_flutter/flutter.dart'  as charts;
  
  
  class PostDetailsPage extends StatelessWidget{
      static String tag = 'post-details-page';
    final List&lt;charts.Series&gt; seriesList;
    final bool animate;
  
    PostDetailsPage(this.seriesList, {this.animate});
  
    /// Creates a [BarChart] with sample data and no transition.
    factory PostDetailsPage.withSampleData() {
      return new PostDetailsPage(
        _createSampleData(),
        // Disable animations for image tests.
        animate: false,
      );
    }
  
  
    @override
    Widget build(BuildContext context) {
      return new charts.BarChart(
        seriesList,
        animate: animate,
      );
    }
  
    /// Create one series with sample hard coded data.
    static List&lt;charts.Series&lt;OrdinalSales, String&gt;&gt; _createSampleData() {
      final data = [
        new OrdinalSales('2014', 5),
        new OrdinalSales('2015', 25),
        new OrdinalSales('2016', 100),
        new OrdinalSales('2017', 75),
      ];
  
      return [
        new charts.Series&lt;OrdinalSales, String&gt;(
          id: 'Sales',
          colorFn: (_, __) =&gt; charts.MaterialPalette.blue.shadeDefault,
          domainFn: (OrdinalSales sales, _) =&gt; sales.year,
          measureFn: (OrdinalSales sales, _) =&gt; sales.sales,
          data: data,
        )
      ];
    }
  }
  
  /// Sample ordinal data type.
  class OrdinalSales {
    final String year;
    final int sales;
  
    OrdinalSales(this.year, this.sales);
  }
  </code></pre>
  
  <p><strong>UPDATED 2: FIXED</strong></p>
  
  <p><em>Main.dart</em></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:fluttercrud/screens/login_page.dart';
  import 'package:fluttercrud/screens/home_page.dart';
  import 'package:fluttercrud/screens/partials/list_post.dart';
  import 'package:fluttercrud/screens/maps_page.dart';
  import 'package:fluttercrud/screens/post_details_page.dart';
  
  void main() =&gt; runApp(MyApp());
  
  class MyApp extends StatelessWidget {
    final routes = &lt;String, WidgetBuilder&gt;{
      LoginPage.tag: (context) =&gt; LoginPage(),
      HomePage.tag: (context) =&gt; HomePage(),
      ListPost.tag: (context) =&gt; ListPost(),
      MapsPage.tag: (context) =&gt; MapsPage(),
      PostDetailsPage.tag: (context) =&gt; PostDetailsPage(),
    };
  
    @override
    Widget build(BuildContext context) {
      return MaterialApp(
        title: 'iGota',    
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch  : Colors.blue,
        ),
        home: LoginPage(),
        routes: routes,
      );
    }
  }
  </code></pre>
  
  <p><em>PostDetailsPage.dart</em></p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:charts_flutter/flutter.dart' as charts;
  
  class PostDetailsPage extends StatefulWidget {
    static String tag = 'post-details-page';
  
    @override
    PostDetailsPageState createState() =&gt; new PostDetailsPageState();
  }
  
  class PostDetailsPageState extends State&lt;PostDetailsPage&gt; {
    List&lt;charts.Series&gt; seriesList = [];
    bool animate;
  
    void initState() {
      super.initState();
      seriesList = _createSampleData();
      animate = false;
    }
  
    @override
    Widget build(BuildContext context) {
      return new Container(
        decoration: new BoxDecoration(color: Colors.white),
        child: new charts.BarChart(
          seriesList,
          animate: animate,
        ),
      );
    }
  
    /// Create one series with sample hard coded data.
    static List&lt;charts.Series&lt;OrdinalSales, String&gt;&gt; _createSampleData() {
      final data = [
        new OrdinalSales('2014', 5),
        new OrdinalSales('2015', 25),
        new OrdinalSales('2016', 100),
        new OrdinalSales('2017', 75),
      ];
  
      return [
        new charts.Series&lt;OrdinalSales, String&gt;(
          id: 'Sales',
          colorFn: (_, __) =&gt; charts.MaterialPalette.blue.shadeDefault,
          domainFn: (OrdinalSales sales, _) =&gt; sales.year,
          measureFn: (OrdinalSales sales, _) =&gt; sales.sales,
          data: data,
        )
      ];
    }
  }
  
  /// Sample ordinal data type.
  class OrdinalSales {
    final String year;
    final int sales;
  
    OrdinalSales(this.year, this.sales);
  }
  </code></pre>