- Fork and clone this into your development folder.
- Install the
go_router
package.
flutter pub add go_router
- Import your package in your
main.dart
file.
import 'package:go_router/go_router.dart';
- Create your routes so the
home_screen.dart
be the main screen andsigned_in.dart
on the path/signin
. - Replace the
MaterialApp
with aMaterialApp.router
. - In your
signed_in.dart
page, create a variable to hold theusername
. - Fix the constructor for the
signed_in.dart
widget. - In your
main.dart
/signin
route, pass the username as aString
. - In your
home_screen.dart
ElevatedButton
onPressed
method, check if thepassword
is equal to the String12345
and then navigate the user to the/signed_in
page and pass theusername
as extra. - In your
signed_in.dart
display a welcome message in theText
widget with the username we got.
After the user is signed in, we don't want him to be able to go back to the signin form.
Open the go_router
docs and explore the go
method instead of the push
method.
git add .
git commit -m "your message"
git push