如何解决没有找到材质小部件颤动与代码
我正在使用 VS Code 在 Flutter 中设置 TextField 小部件,但在 TextFormField 上出现此错误:
No Material widget found.
TextField widgets require a Material widget ancestor.
I/Flutter ( 3827): In material design,most widgets are conceptually "printed" on a sheet of material. In Flutter's
I/Flutter ( 3827): material library,that material is represented by the Material widget. It is the Material widget
I/Flutter ( 3827): that renders ink splashes,for instance. Because of this,many material library widgets require that
I/Flutter ( 3827): there be a Material widget in the tree above them.
I/Flutter ( 3827): To introduce a Material widget,you can either directly include one,or use a widget that contains
I/Flutter ( 3827): Material itself,such as a Card,Dialog,Drawer,or Scaffold.
I/Flutter ( 3827): The specific widget that Could not find a Material ancestor was:
I/Flutter ( 3827): TextField
I/Flutter ( 3827): The ancestors of this widget were:
I/Flutter ( 3827): ...
I/Flutter ( 3827): TextFormField
I/Flutter ( 3827): Column
I/Flutter ( 3827): Padding
I/Flutter ( 3827): Padding
I/Flutter ( 3827): Container
TextFormField 的代码是:
TextFormField txtEmail(String title,IconData icon) {
return TextFormField(
controller: emailController,style: TextStyle(color: Colors.white70),decoration: Inputdecoration(
hintText: title,hintStyle: TextStyle(color: Colors.white70),icon: Icon(icon)),);
}
实际上我在此调用 txtEmail:
Container textSection() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 20.0),margin: EdgeInsets.only(top: 30.0),child: Column(
children: <Widget>[
txtEmail("Email",Icons.email),SizedBox(height: 30.0),txtPassword("Password",Icons.lock),],),);
}
是什么原因?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。