getControllerForState function
Allows getting an AuthController that caused an AuthState transition. Calling getControllerForState is only allowed from a FirebaseUIAction callback:
SignInScreen(
actions: [
AuthStateChangeAction<SignedIn>((context, state) {
final ctrl = getControllerForState(state);
if (ctrl is EmailAuthController) {
print('email was used for authentication');
}
Navigator.of(context).pushReplacementNamed('/profile');
}
]
);
Implementation
AuthController getControllerForState(AuthState state) {
final ctrl = _controllerRegistry[state];
if (ctrl == null) {
throw StateError(
'Quering controller for an auth state is only allowed '
'from FirebaseUIAction callback',
);
}
return ctrl;
}