Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Last active April 28, 2021 21:46
Show Gist options
  • Save sendbird-community/6395e010f2afb7df4cee81577a4a3609 to your computer and use it in GitHub Desktop.
Save sendbird-community/6395e010f2afb7df4cee81577a4a3609 to your computer and use it in GitHub Desktop.
Flutter | Create a list view with application users
Widget body(BuildContext context) {
return ListView.builder(
itemCount: _availableUsers.length,
itemBuilder: (context, index) {
User user = _availableUsers[index];
return CheckboxListTile(
title: Text(user.nickname.isEmpty ? user.userId : user.nickname,
style: TextStyle(color: Colors.black)),
controlAffinity: ListTileControlAffinity.platform,
value: _selectedUsers.contains(user),
// value: SendbirdSdk().currentUser.userId == user.userId,
activeColor: Theme.of(context).primaryColor,
onChanged: (bool value) {
// Using a set to store which users we want to create
// a channel with.
setState(() {
if (value) {
_selectedUsers.add(user);
} else {
_selectedUsers.remove(user);
}
print(
'create_channel_view: on change for: ${user.nickname} _selectedUsers: $_selectedUsers');
});
},
secondary: user.profileUrl.isEmpty
? CircleAvatar(
child: Text(
(user.nickname.isEmpty ? user.userId : user.nickname)
.substring(0, 1)
.toUpperCase(),
))
: CircleAvatar(
backgroundImage: NetworkImage(user.profileUrl),
),
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment