该网站上存在一些类似的问题,但我无法完全弥补
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),
);
},
);
}
},
);
}
这是我的代码,在生成器所在的标题中得到警告。
如果有人提出解决方案或想法,我将不胜感激:)
答案 0 :(得分:3)
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),
);
},
);
}
return Container(); // you need to return any widget from here. You could use CircularProgressIndicator() also.
},
);
}