Flutter error: Each child must be laid out exactly once. On building layout(颤振错误:每个孩子必须恰好布置一次.关于建筑布局)
问题描述
我正在使用flutter_bloc.
I'm using flutter_bloc.
我有这样的代码:
class Settings extends StatelessWidget {
final _formKey = GlobalKey<FormState>();
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(
title: new Text("SomeApp",style: TextStyle(color: Colors.white)),
automaticallyImplyLeading: false,
backgroundColor: myBlue.shade50,
actions: <Widget>[
IconButton(
icon: new Icon(FontAwesomeIcons.download,color: Colors.white),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => DownloadView()),
);
},
),
IconButton(
icon: new Icon(FontAwesomeIcons.chevronCircleLeft,color: Colors.white),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MainWindow()),
);
},
),]
),
body: Container(
padding: EdgeInsets.symmetric(vertical: 16),
alignment: Alignment.center,
child: new BlocBuilder<SettingsBloc, SettingsState>(
builder: (context, state) {
if (state is SettingsNotLoaded) {
return new Center(
child: Text(
'count1',
style: TextStyle(fontSize: 24.0,color: Colors.black),
)
);
} else if (state is SettingsLoaded) {
return new Center(
child: Text(
'count2',
style: TextStyle(fontSize: 24.0,color: Colors.black),
)
);
}
else
{
return new Center(
child: Text(
'count3',
style: TextStyle(fontSize: 24.0,color: Colors.black),
)
);
}
},
),
),
);
}
当启动我的应用程序时,我看到了我想要的 appBar,但我没有看到正文中的任何文本(我应该看到 count1、count2 或 count3),但我得到了错误:
And when starting my app I see the appBar just the way I want, but I do not see any text in body (I should see either count1, count2 or count3), but instead I get the error:
每个孩子必须恰好布置一次."参考第 5 行 - return new Scaffold(
Each child must be laid out exactly once." referring to line 5 -
return new Scaffold(
当然,我在 https://flutter 上查找了 flutter_bloc 页面上的信息.dev/docs/development/ui/layout/tutorial ,在此处和在 google 中也是如此.
Of course, I looked for info on flutter_bloc page, on https://flutter.dev/docs/development/ui/layout/tutorial ,here and in google as well.
推荐答案
我只是遇到了同样的问题,我认为它只是颤振中的一个错误.停止并重新安装您的应用
I just had the same problem I think its just a bug in flutter. Stop and then reinstall your app
这篇关于颤振错误:每个孩子必须恰好布置一次.关于建筑布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:颤振错误:每个孩子必须恰好布置一次.关于建筑布局
基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01