Progress bar while logging in with firebase Flutter
400
Since you use future, the best way would be to control a CircularProgressIndicator()
with a boolean inside your method like this:
Future<void> validateAndSubmit() async {
setState(( {
_isLoading = true;
});
if (validateAndSave()) {
try {
final Auth auth = await AuthFactory.getAuth();
final String userId = await auth
.signInWithEmailAndPassword(_email, _password)
.whenComplete(() =>
{
setState(() {
_isLoading = false;
});
Navigator.of(context).popAndPushNamed(RootPage.routeName));
}
print('Signed In:$userId');
} catch (e) {
print('Error:$e');
print(e.toString());
}
}
}
and then somewhere in your widget tree:
_isLoading ? CircularProgressIndicator() : Other widget...
Author by
Luthermilla Ecole
Updated on December 26, 2022Comments
-
Luthermilla Ecole over 1 year
I am building an application, and I would like to show a progress bar while the user is waiting to be logged-in in the platform.
How can I add a circle progress bar while I am awaiting?
Future<void> validateAndSubmit() async { if (validateAndSave()) { try { final Auth auth = await AuthFactory.getAuth(); final String userId = await auth .signInWithEmailAndPassword(_email, _password) .whenComplete(() => Navigator.of(context).popAndPushNamed(RootPage.routeName)); print('Signed In:$userId'); } catch (e) { print('Error:$e'); print(e.toString()); } } }