我是新手,请为新手提问/术语道歉
我正在尝试整理应用程序的主屏幕代码,因此我将小部件从脚手架小部件的主体部分移至单独的功能,但似乎当我设置单独的函数以返回小部件时, Dart Analysis说它什么也不会返回,但是据我了解,它应该已经返回了ListView
Widget _buildChatPage(BuildContext context) {
chatUsers == null
? Container(
alignment: Alignment.center,
child: CircularProgressIndicator(),
)
: chatUsers.length == 0
? NoDataView()
: ListView.separated(
itemCount: chatUsers.length,
itemBuilder: (context, index) {
User _user = chatUsers[index];
return ListTile(
leading: CircleAvatar(
child: ClipOval(
child: ImageView(
_user.profilePic,
ImageType.URL,
fit: BoxFit.cover,
height: 50.0,
width: 50.0,
placeHolderImagePath: 'images/user.png',
),
clipBehavior: Clip.hardEdge,
),
radius: 25.0,
),
title: Text(_user.name),
subtitle: Text(_user.email),
onTap: () async {
if (widget.user == null) {
await getCurrentUser();
}
if (widget.user != null && _user != null) {
Map users = {
'primaryUser': widget.user,
'secondaryUser': _user,
};
Navigator.of(context)
.pushNamed('/chat', arguments: users);
}
},
);
},
separatorBuilder: (context, index) => Divider(),
);
}
答案 0 :(得分:1)
添加类似的返回语句
Widget _buildChatPage(BuildContext context) {
return
chatUsers == null
? Container(