我是颤振新手。我正在尝试将多个数据发送到另一个屏幕:
// screen1.dart
..
Expanded(
child: RaisedButton(
onPressed: () {
Navigator.push(context,
MaterialPageRoute(
builder: (context) => new Screen2(name: thing.name, email: thing.email, address: thing.address, etc..),
),
);
},
),
),
..
// screen2.dart
class Screen2 extends StatefulWidget{
Screen2({this.name}, {this.email}, {this.address}, etc..);
final String name;
final String email;
final String address;
// etc
@override
State<StatefulWidget> createState() { return new Screen2State();}
}
class Screen2State extends State<Screen2> {
Widget build(BuildContext context) {
return new WillPopScope(
..
child: Scaffold(
..
new Row(
children: <Widget>[
new Text(widget.name),
new Text(widget.email),
new Text(widget.address),
etc..
],
),
)
)
}
Run Code Online (Sandbox Code Playgroud)
但我收到错误:A non-null String must be provided to a Text widget.
数据从 TextEditingController 传输。仅传输 1 个数据时有效,但传输 2 个或更多数据时失败。
在屏幕之间发送多个数据的正确方法是什么?
| 归档时间: |
|
| 查看次数: |
11493 次 |
| 最近记录: |