У меня есть текстовое поле с вводом: Foo / line1 Bar / line2
, когда я нажимаю кнопку submit, я создаю виджеты 'Name:' со значением, которое было отправлено (name = foo и name = bar),как создать и получить значение из этого текстового поля?я должен сначала сделать построитель представления списка?
кто-нибудь может привести пример,
String txt = "";
TextEditingController controllerTxt = new TextEditingController();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: Text('Create'),
actions: <Widget>[
FlatButton(
child: Text('Submit'),
textColor: Colors.white,
onPressed: () {
Navigator.pushNamed(context, '/ResultPage',
arguments: (controllerTxt.text));
},
),
],
),
body: new ListView(
children: <Widget>[
new Container(
child: new Column(
children: <Widget>[
new TextField(
controller: controllerTxt,
maxLines: 25,
),
],
),
),
],
),
);
}
class _ResultPageState extends State<ResultPage> {
String result;
@override
Widget build(BuildContext context) {
RouteSettings settings = ModalRoute.of(context).settings;
result = settings.arguments;
return new Scaffold(
appBar: new AppBar(
title: Text('Create'),
actions: <Widget>[
],
),
body: new Container(
padding: EdgeInsets.all(10.0),
child: new Row(
children: <Widget>[
new Text('Name : '),
Expanded(
child: new TextField(
enabled: false,
decoration: new InputDecoration(
border: new OutlineInputBorder(
borderSide: new BorderSide(color: Colors.black)),
labelText: ('${result}'),
),
)),
],
),
),
);
}
}