AuthFlowBuilder<T extends AuthController> constructor

const AuthFlowBuilder<T extends AuthController>({
  1. Key? key,
  2. Object? flowKey,
  3. AuthAction? action,
  4. AuthFlowBuilderCallback<T>? builder,
  5. dynamic onComplete(
    1. AuthCredential credential
    )?,
  6. Widget? child,
  7. StateTransitionListener<T>? listener,
  8. AuthProvider<AuthListener, AuthCredential>? provider,
  9. FirebaseAuth? auth,
  10. AuthFlow<AuthProvider<AuthListener, AuthCredential>>? flow,
})

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',
      );