简体   繁体   中英

send data to new screen in flutter but don't know how to set this

我是开发新手,但不知道如何在颤动中将数据发送到新屏幕我想显示卡中的电影列表,当我单击任何卡时,它会在新屏幕上显示电影的详细信息如果有人帮助我,我非常感谢

// you can have stateful or stateless. This depends on you
class YouScreenName extends StatefulWidget{
  final data;
  YourScreenName({this.data});
} 
Navigator.of(context)
        .push(MaterialPageRoute(
            builder: (BuildContext context) => YourScreenName(
                  data : data
                )));

or

Navigator.of(context).pushedNamed('/your_route', arguments:data);

您只需将数据传递到新页面的构造函数中,然后从构造函数中获取数据并显示到新页面中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM