I'm pretty new to flutter, so apologies for the noob questions/terminologies
I'm trying to tidy up my app's main screen code, so I'm moving widgets from the body part of my scaffold widget to separate functions, but it seems that when I setup a seperate function to return the widget, my Dart Analysis says it doesn't return anything, but from my understanding, it supposedly returned a ListView already
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(),
);
}
Add return statement like
Widget _buildChatPage(BuildContext context) {
return
chatUsers == null
? Container(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With