How can I view the details of an item in a detailed screen - Flutter

后端 未结 2 944
遇见更好的自我
遇见更好的自我 2021-01-26 08:16

I am new to flutter this error is giving me a serious nightmare. I have a card list of items called Anchors. These items are coming from the shared preference file which belongs

2条回答
  •  不要未来只要你来
    2021-01-26 08:56

    first screen onPressed get the index and assigned it to variable, or you can just pass i varibale too,

         onPressed: () {
             Navigator.push(context,new MaterialPageRoute(builder: (context) =>
                  detailsPage(i))); },
    

    In detailed page

        class detailsPage extends StatefulWidget {
            final int selectedIndex;
            detailsPage(this.selectedIndex,{Key key}) : super(key: key);
    
           @override
            _detailsPageState createState() => _detailsPageState();
           }
    

    place that you want to use the previous page passsed index,

        return Text(value[widget.selectedIndex]['DistributionCentres'][i]['Name']);
    

    Hope this will help..

提交回复
热议问题