我在登录屏幕上有这些代码段,这些代码在我在android设备上启动应用程序时不会显示
此处控制台I / flutter上的错误(12389):渲染库引起的异常╞═════════════════════════ ════════════════════════════════ I / flutter(12389):在performLayout()期间引发了以下断言: I / flutter(12389):BoxConstraints强制无限宽度。 I / flutter(12389):这些无效约束是由RenderAnimatedOpacity的layout()函数提供给 I / flutter(12389):以下函数,该函数可能计算了有问题的无效约束:
import 'package:flutter/material.dart';
class UserEmail extends StatefulWidget{
@override
State<StatefulWidget> createState() {
return UserEmailState();
}
}
class UserEmailState extends State<UserEmail> {
final TextEditingController _emailController = new TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: new AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
),
body: ListView(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),
child: SizedBox(
child: new Row(
children: <Widget>[
Text("Welcome",
style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold
),),
Text("A short slogan about the app...")
],
),
),
),
Padding(
padding: const EdgeInsets.all(24.0),
child: SizedBox(
child: Column(
children: <Widget>[
Row(
children: <Widget>[
TextField(
controller: _emailController,
decoration: new InputDecoration(
labelText: "Email",
hintText: "Enter email address"
),
)
],
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new RaisedButton(
onPressed: null,
textColor: Colors.white,
color: Colors.blueGrey,
padding: const EdgeInsets.all(8.0),
child: new Text(
"Continue")
),
),
],
),
),
)
],
),
);
}
}
答案 0 :(得分:0)
将TextField包裹在Expanded或Flexible窗口小部件中。像这样:
Flexible(
child: TextField(
controller: _emailController,
decoration: new InputDecoration(
labelText: "Email",
hintText: "Enter email address"
),
),
)