gpt4 book ai didi

android - Flutter 错误 : Each child must be laid out exactly once. 关于建筑布局

转载 作者:行者123 更新时间:2023-12-03 13:24:30 26 4
gpt4 key购买 nike

我正在使用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),但我得到了错误:

Each child must be laid out exactly once." referring to line 5 - return new Scaffold(


当然,我在 https://flutter.dev/docs/development/ui/layout/tutorial 上的 flutter_bloc 页面上查找了信息。 ,这里和谷歌也是如此。

最佳答案

我只是遇到了同样的问题,我认为它只是 flutter 中的一个错误。停止然后重新安装您的应用程序

关于android - Flutter 错误 : Each child must be laid out exactly once. 关于建筑布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60076949/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com