Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created April 28, 2021 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sendbird-community/0bfe92f9390938d083ca28a744fba4c3 to your computer and use it in GitHub Desktop.
Save sendbird-community/0bfe92f9390938d083ca28a744fba4c3 to your computer and use it in GitHub Desktop.
Flutter | Navigation bar with createChannels
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: navigationBar(),
body: body(context),
);
}
Widget navigationBar() {
return AppBar(
automaticallyImplyLeading: true,
leading: BackButton(color: Theme.of(context).buttonColor),
backgroundColor: Colors.white,
title: Text(
'Select members',
style: TextStyle(color: Colors.black),
),
actions: [
TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).buttonColor)),
onPressed: () {
if (_selectedUsers.toList().length < 2) {
// Don't create a channel if there aren't at least 2 users selected
return;
}
createChannel(
[for (final user in _selectedUsers.toList()) user.userId])
.then((channel) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => GroupChannelView(groupChannel: channel),
),
);
}).catchError((error) {
print(
'navigationBar: createChannel: ERROR: $error');
});
},
child: Text(
"Create",
style: TextStyle(
fontSize: 20.0,
color: Theme.of(context).primaryColor,
),
),
)
],
centerTitle: true,
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment