I just want to pass the int and boolean from one class to another class. For that particular integer can be displayed in the app bar of the second page, background color needs to be changed based on boolean (True/false). 解决方案 In navigator you can pass data or object which you want to send to other class.For example,// Data need to sent second screenclass Person { final String name; final String age; Person(this.name, this.age);}// Navigate to second screen with dataNavigator.push(context, new MaterialPageRoute(builder: (context) => new SecondScreenWithData(person: new Person("Priyank","28"))));In SecondScreenWithData class, you can get passed data as below.class SecondScreenWithData extends StatelessWidget { // Declare a field that holds the Person data final Person person; // In the constructor, require a Person SecondScreenWithData({Key key, @required this.person}) : super(key: key); @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text("Second Screen With Data"), ), body: new Center( child: new Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: <Widget>[ // Display passed data from first screen new Text("Person Data \nname: ${person.name} \nage: ${person.age}"), new RaisedButton( child: new Text("Go Back!"), onPressed: () { // Navigate back to first screen when tapped! Navigator.pop(context); } ), ], ) ), ); }Check full Navigation Demo 这篇关于Flutter-我想将变量从一类传递到另一类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 10:33