AuthFlowBuilder<T extends AuthController> constructor
const
AuthFlowBuilder<T extends AuthController> ({
- Key? key,
- Object? flowKey,
- AuthAction? action,
- AuthFlowBuilderCallback<
T> ? builder, - dynamic onComplete(
- AuthCredential credential
- Widget? child,
- StateTransitionListener<
T> ? listener, - AuthProvider<
AuthListener, AuthCredential> ? provider, - FirebaseAuth? auth,
- AuthFlow<
AuthProvider< ? flow,AuthListener, AuthCredential> >
A widget that is used to wire up the AuthFlows with the widget tree.
Could be used to build a custom UI and facilitate the built-in functionality of the all available AuthFlows:
An example of how to build a custom email sign up form using AuthFlowBuilder:
final emailCtrl = TextEditingController();
final passwordCtrl = TextEditingController();
AuthFlowBuilder<EmailAuthController>(
auth: fba.FirebaseAuth.instance,
action: AuthAction.signUp,
listener: (oldState, newState, ctrl) {
if (newState is UserCreated) {
Navigator.of(context).pushReplacementNamed('/profile');
}
},
builder: (context, state, ctrl, child) {
if (state is AwaitingEmailAndPassword) {
return Column(
children: [
TextField(
decoration: InputDecoration(labelText: 'Email'),
controller: emailCtrl,
),
TextField(
decoration: InputDecoration(labelText: 'Password'),
controller: passwordCtrl,
),
OutlinedButton(
child: Text('Sign Up'),
onPressed: () {
ctrl.setEmailAndPassword(emailCtrl.text, passwordCtrl.text);
}
),
]
);
} else if (state is SigningIn) {
return Center(child: CircularProgressIndicator());
} else if (state is AuthFailed) {
return ErrorText(exception: state.exception);
}
}
)
Implementation
const AuthFlowBuilder({
super.key,
this.flowKey,
this.action,
this.builder,
this.onComplete,
this.child,
this.listener,
this.provider,
this.auth,
this.flow,
}) : assert(
builder != null || child != null,
'Either child or builder should be provided',
);