【发布时间】:2020-08-03 10:26:15
【问题描述】:
我对一件简单的事情有疑问,但我不知道它是如何在代码中发生的。 下面是代码:
Widget build(BuildContext context) {
String newTaskTitle;
return Container(
color: Color(0xff757575),
child: Container(
padding: EdgeInsets.all(20.0),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(
'Add Task',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30.0,
color: Colors.lightBlueAccent,
),
),
TextField(
autofocus: true,
textAlign: TextAlign.center,
onChanged: (newText) {
newTaskTitle = newText;
},
),
FlatButton(
child: Text(
'Add',
style: TextStyle(
color: Colors.white,
),
),
color: Colors.lightBlueAccent,
onPressed: () {
print(newTaskTitle);
},
),
],
),
),
);
}
【问题讨论】:
-
您是否在另一棵树中使用
widget tree? -
我将此屏幕放在底部弹出屏幕中。
-
请发布您在哪里使用此
widget tree的完整代码 sn-p,以便我可以帮助解决它的问题。
标签: android flutter dart mobile