I have a Flutter app in which admins can create accounts (using Firebase Authentication) for other users.
My logic is similar to the following:
UserCredential userCredential =
await authService.instance.createUserWithEmailAndPassword(
email: emailController.text,
password: passwordController.text,
);
main.dart
:
MaterialApp(
home: StreamBuilder<User>(
stream: authentcationService.authStateChanges,
builder: (context, snapshot) {
// Build the app
// ...
},
)
)
However I noticed that this is triggering an auth state change in the stream
above: calling createUserWithEmailAndPassword
is logging out the current user and logging in the newly-created user, rather than simply creating a new user in Firebase Authentication. Can anyone advise?