Skip to content

Instantly share code, notes, and snippets.

@nparsons08 nparsons08/new_channel.dart Secret
Created Mar 2, 2020

Embed
What would you like to do?
// mobile/lib/new_channel.dart:14
class _NewChannelState extends State<NewChannel> {
final _channelIdController = TextEditingController();
Future _createChannel(BuildContext context) async {
if (_channelIdController.text.length > 0 && RegExp(r'^[a-zA-Z0-9]+$').hasMatch(_channelIdController.text)) {
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (_) => LivestreamChat(account: widget.account, channelId: _channelIdController.text),
),
result: true);
} else {
Scaffold.of(context).showSnackBar(
SnackBar(
content: Text('Please type a channel ID. It can only contain letters and numbers with no whitespace.'),
),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Create New Channel"),
),
body: Builder(
builder: (context) {
return Container(
padding: EdgeInsets.all(12.0),
child: Center(
child: Column(
children: [
TextField(
controller: _channelIdController,
),
RaisedButton(
onPressed: () => _createChannel(context),
child: Text("Create Channel"),
),
],
),
),
);
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.