title: send data from one screen to another screen flutter
body: <p>I am trying to pass data from one screen to another screen.</p>
  
  <pre><code>List&lt;SubCategoryData&gt;categoryNames = new List&lt;SubCategoryData&gt;();
    List&lt;String&gt;categorieslist = [];
    bool isFirst=true;
  
    Future&lt;SubCategoryModel&gt;fetchCategories(BuildContext context) async {
  
      String url = "http://106.51.64.251:380/onnet_api/subcatListByCategory.php";
  
      var body = new Map&lt;String,String&gt;();
      body['publisherid']= 102.toString();
      body['tag'] = "category";
      body['subtag']= "list";
      body['parentId'] = 10.toString();
  
      http.Response res = await http.post(url,body: body);
      final categoryjsondata = json.decode(res.body);
      var map = Map&lt;String,dynamic&gt;.from(categoryjsondata);
      var categoryResponse = SubCategoryModel.fromJson(map);
  
      if(res.statusCode == 200){
        print('category Response: $categoryResponse');
        if(categoryResponse.status == 1){
          //final categoryModel = json.decode(res.body);
          var data = categoryjsondata['data']as List;
          print('category data: $data');
  
        /*  for(var model in categorieslist){
            categoryNames.add(new SubCategoryData.fromJson(model));
          }*/
      /*    SharedPreferences prefs = await SharedPreferences.getInstance();
          print("cat List Size: $categories");
          prefs.setStringList("categorylist", categories);*/
          Navigator.push(context, MaterialPageRoute(builder: (context)=&gt; ChewieDemo(imageData: images[0],
              categoryData:data)));
        }
      }
    }
  </code></pre>
  
  <p>By using the above code I am trying to send data but I am facing issue like  <strong>type 'List' is not a subtype of type 'SubCategoryData' in type cast"</strong></p>
  
  <p>got an error and even I am not getting how to send data with an index value.Please let me know.</p>
  
  <p>Below is my <strong>ChewieDemo</strong> class: 
  Here I am trying to receive the data from another class.</p>
  
  <pre><code>class ChewieDemo extends StatefulWidget {
  
    final Datum imageData;
    final SubCategoryData categoryData;
    ChewieDemo({this.title = 'Player',Key key,@required this.imageData,@required this.categoryData}): super(key:key);
    final String title;
  
    @override
    State&lt;StatefulWidget&gt; createState() {
      return _ChewieDemoState();
    }
  }
  
  class _ChewieDemoState extends State&lt;ChewieDemo&gt; {
  
    TargetPlatform _platform;
    VideoPlayerController _videoPlayerController1;
    VideoPlayerController _videoPlayerController2;
    ChewieController _chewieController;
  
    @override
    void initState() {
      super.initState();
      print('url player :${widget.imageData.dataUrl}');
      print(widget.categoryData);
      // 'https://www.sample-videos.com/video123/mp4/480/big_buck_bunny_480p_20mb.mp4'
      _videoPlayerController1 = VideoPlayerController.network('${widget.imageData.dataUrl}');
      _chewieController = ChewieController(
        videoPlayerController: _videoPlayerController1,
        aspectRatio: 3 / 2,
        autoPlay: true,
        looping: true,
        // Try playing around with some of these other options:
  
        // showControls: false,
        // materialProgressColors: ChewieProgressColors(
        //   playedColor: Colors.red,
        //   handleColor: Colors.blue,
        //   backgroundColor: Colors.grey,
        //   bufferedColor: Colors.lightGreen,
        // ),
        // placeholder: Container(
        //   color: Colors.grey,
        // ),
        // autoInitialize: true,
      );
    }
  </code></pre>
  
  <p>This is the model class of SubCategoryData.</p>
  
  <pre><code>class SubCategoryData {
        int id;
        int parentId;
        String name;
        int contentCount;
        String createdAt;
        int status;
  
        SubCategoryData({
          this.id,
          this.parentId,
          this.name,
          this.contentCount,
          this.createdAt,
          this.status,
        });
  
        factory SubCategoryData.fromJson(Map&lt;String, dynamic&gt; json) =&gt; new SubCategoryData(
          id: json["id"],
          parentId: json["parent_id"],
          name: json["name"],
          contentCount: json["content_count"],
          createdAt: json["createdAt"],
          status: json["status"],
        );
  
        Map&lt;String, dynamic&gt; toJson() =&gt; {
          "id": id,
          "parent_id": parentId,
          "name": name,
          "content_count": contentCount,
          "createdAt": createdAt,
          "status": status,
        };
  
        @override
        String toString() {
          // TODO: implement toString
          return '$id $parentId $name $contentCount';
        }
      }
  </code></pre>