【发布时间】:2021-06-09 17:14:29
【问题描述】:
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Todo Add'),
centerTitle: true,
),
body: Container(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 10),
child: Column(
children: [
TextField(
controller: controller,
onChanged: (value) => title = value,
decoration: InputDecoration(hintText: 'Enter your title'),
),
SizedBox(
height: 10,
),
TextField(
controller: controller1,
onChanged: (val) => body = val,
decoration: InputDecoration(hintText: 'Enter your body'),
),
SizedBox(
height: 40,
),
ElevatedButton(
onPressed: () {
setText();
},
child: Text("Submit"),
),
Text(
'Title : $text',
style: TextStyle(fontSize: 16),
),
SizedBox(height: 10,),
Text(
'Body : $desc',
style: TextStyle(fontSize: 16),
),
],
),
),
),
);
}
【问题讨论】:
-
请编辑您的代码,它不可读。
-
我把你的代码放在一个代码块中,这样它就可以阅读了,但你仍然需要解释你在问什么(你所说的“另一个屏幕”是什么意思?)
-
我想创建一个 TextField 值的实例,这样我就可以使用这个值或在任何其他屏幕上打印它