Flutter • Firebase • BLoC Tutorial #8 - Authentication Screen
ฝัง
- เผยแพร่เมื่อ 15 ต.ค. 2024
- Hello, in this Flutter & Firebase tutorial series, we'll build a complete app with a database (Firebase Firestore) and an authentication system (using Firebase auth).
------------------------------
GitHub: github.com/rom...
Subscribe !!
Great Tutorial, a bit tough for beginners because of the copy pasta, but the flow is very very solid.
Love it!
Great tutorial! this series is helping me a lot.
Im having an issue, when I register the user everything works fine on the sign up but the screen doesn't return to the homepage (when I restart the app it works), this just happens when I use routes, the blocBuilder return the login page when not logged and from the login page I navigate to the /register route.
Like this:
home: BlocBuilder(
builder: (context, state) {
if (state.status == AuthenticationStatus.authenticated) {
return const Home();
} else {
return const LoginPage();
}
},
),
routes: {
// '/': (context) => const Home(),
'/login': (context) => const LoginPage(),
'/register': (context) => const RegisterPage(),
},
Hello !
I will do a video on Routes because they are a bit special to understand at fitst. But basically here, you have a "home" parameter and in the "routes" parameter defined as well the "initial route" with " / ".
So when you are doing the login, you need to navigate manualy to the Home page perhaps by using "popAndPush" or something like this.
@@Romain_Girou Got it! thanks!
A video on routes would be great
thanks Romain great tutorial, I have a doubt why are you using the setstate to update the bool value, can we update the state without setstate (using bloc )? If yes how can we do that, i guess using setstate in code multipal time is not a good programming practice and thank you once again :)
well it's not because you are using a state management system like bloc that you don't need setstate. If you have a bool value define in WidgetA and you need to change it's value you'll need to call setstate. even if you use bloc and the bloc state changes and you use a bloclistener to catch this state changes, you'll still need to call setstate to modify the UI if any modifications are neeeded.
I hope I was clear, nothing can change on the UI without calling setstate
thank you very much for this content, I wish I could do a good job like you in future.
just a question, is there better way than using setstate (stateful W in general)?
Thank you so much ☺️
Stateful widgets should be use only when you need the widget to be dynamic meaning some data will need to update with set state otherwise it’s better to use stateless when possible
@@Romain_Girou i mean like using provider with bloc, is it better ?
❤❤❤
Great tutorial....The prefix icon doesn't appear on my screen until i tap on it.
Thank you !
That's weird, perhaps a relaunch or some package are missing ?