Created
April 21, 2022 11:29
-
-
Save rifkyputra/bb25d5a31c76cf0c702fb60f52a469ac to your computer and use it in GitHub Desktop.
Revisions
-
rifkyputra created this gist
Apr 21, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,47 @@ class RegisterUserPage extends StatefulWidget { const RegisterUserPage({Key? key}) : super(key: key); static const String routeName = 'RegisterUserPage'; @override State<RegisterUserPage> createState() => _RegisterUserPageState(); } class _RegisterUserPageState extends State<RegisterUserPage> { final TextEditingController textEditingController = TextEditingController(); String username = ''; @override Widget build(BuildContext context) { return BlocListener<AppCubit, AppState>( listener: (context, state) { if (state.username != null) { Navigator.of(context).pushNamed(ChatRoomPage.routeName); } }, child: Scaffold( body: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, children: [ TextField( controller: textEditingController, decoration: const InputDecoration( hintText: 'Enter Username', ), onChanged: (value) => setState(() => username = value), ), const SizedBox(height: 40), ElevatedButton( onPressed: () => context.read<AppCubit>().saveUsername(username), style: ElevatedButton.styleFrom( shape: const StadiumBorder(), ), child: Text('Enter'), ), ], ), ), ); } }