Created
April 28, 2021 18:13
-
-
Save sendbird-community/0bfe92f9390938d083ca28a744fba4c3 to your computer and use it in GitHub Desktop.
Flutter | Navigation bar with createChannels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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