In this PR, I am upgrading the firebase-emulator-suite
code to use go_router
, as part of the work on migrating all relevant codelabs to go_router
.
This codelab follows https://firebase.google.com/codelabs/get-started-firebase-emulators-and-flutter#0 ping @ericwindmill as they are the owner of the codelab.
I had a bit of problem running the codelab (independently of the change to go_router), which I explain here:
- The
AndroidManifest.xml
needed android:usesCleartextTraffic="true"
to be able to talk to the Firebase emulators.
- The
minSdkVersion
had to be increased to 19
(from the default of 16
)
- The shipped Firebase packages were not compatible anymore and had to be upgraded to the latest versions.
- The Android project needed the MultiDex setup to run.
- Before running the project for the first time, I had to fix the problem detailed here: https://stackoverflow.com/questions/64962297/why-do-i-keep-receiving-an-error-when-initializing-my-firebase-project-while-set I think the codelab doesn't explain this step (or I skipped it, sorry!)
I committed some changes to fix these issues, others will need to be fixed in the codelab document.
Explaining the list of changes:
- The codelab code uses now
go_router
, replacing the named routes.
- The "logout" state is handled by having the
user
object as null
, this is implemented with GoRouter
redirect
parameter.
- The paths have been adjusted,
/
is now /login
, and /home
is now /
.
- The app will try to open
/
, will see that the user
is null, and will redirect the user to /login
.
- After the user logs in using Firebase Auth, the app uses
context.go('/')
to go back to the home.
FYI @RedBrogdon
Pre-launch Checklist
- [x] I read the Effective Dart: Style recently, and have followed its advice.
- [x] I signed the CLA.
- [ ] I updated/added relevant documentation (doc comments with
///
). <-- Codelab needs update
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-devrel channel on Discord.