gpt4 book ai didi

flutter - 此函数的返回类型为 'Widget',但不以return语句结尾

转载 作者:行者123 更新时间:2023-12-01 00:11:48 25 4
gpt4 key购买 nike

该网站上存在一些类似的问题,但我无法完全弥补

    Widget _buildBody(tab) {
return BlocBuilder(
bloc: _lessonsBloc,
builder: (BuildContext context, LessonsState state) { //HERE
if (state is LessonsLoading) {
return Center(
child: CircularProgressIndicator(),
);
} else if (state is LessonsLoaded) {
return ListView.builder(

itemCount: state.lessons.length,
itemBuilder: (context, index) {
final displayedLessons = state.lessons[index];
return ListTile(
title: Text(displayedLessons.name),
subtitle:Text(displayedLessons.subname),
trailing: _buildUpdateDeleteButtons(displayedLessons),
);
},
);
}
},
);
}

这是我的代码,在builder所在的标题中得到警告。

如果有人提出解决方案或想法,我将不胜感激:)

最佳答案

您需要从build()方法中返回小部件,但您错过了一个案例。

Widget _buildBody() {
return BlocBuilder(
bloc: _lessonsBloc,
builder: (BuildContext context, LessonsState state) {
if (state is LessonsLoading) {
return Widget1();
} else if (state is LessonsLoaded) {
return Widget2();
}

return CircularProgressIndicator(); // You missed this return statement.
},
);
}

关于flutter - 此函数的返回类型为 'Widget',但不以return语句结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57747280/

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