Future<void> loginWithEmail(
String email,
String password,
) async {
await FirebaseAuth.instance.signInWithEmailAndPassword(email: email, password: password);
final data = await request('fetch-user');
final user = UserV1.fromJson(data);
userBloc.add(UpdateUserAction(user));
fetchAllLogs();
requestPushNotifications();
resetMuscleFreshnessOnLogin();
await fetchUserLights([user.uid]);
await fetchExercises();
// Must be after fetch exercises
generateNextWorkout();
return;
}
In the following code I need to wait for the userBloc to finish. But not sure how to do this. Using the FlutterBloc lib.
It would be nice if I could do
await userBloc.add(UpdateUserAction(user));