Custom Form Fields

For email Sign Up/Sign In you can add/remove form fields.

Addition

  1. Create a field object(Language Field in our case).

  2. Add it to the list of SignUp/SignIn fields.

  3. Pass object to Email Config.

Full Code Sample.

 @override
  Widget build(BuildContext context) {
    final languageField = Field()
      ..attribute = 'language'
      ..labelText = 'Language'
      ..validate = RequiredValidator(errorText: 'Language is required');

    final signUpFields = getSignUpFields();
    signUpFields.add(createField(languageField));

    return MaterialApp(
      title: 'Easy Auth',
      debugShowCheckedModeBanner: false,
      home: SignIn(
        themeColor: Colors.deepPurple,
        // Sign in and Sign Up fields are customizable in EmailConfig
        methods: [Email(config: EmailConfig(signUpFields: signUpFields))],
        auth: FirebaseAuth.instance,
        onSuccess: (user, context, fields) {
          showSnackBar(
              'You made the signUp flow in record time. Cheers.', context);
          print('user: $user \n fields: $fields');
        },
      ),
    );
  }

Removal

In case you want to remove some form fields (Say Confirm Password).

  1. Get the SignUp/SignIn fields.

  2. Pop the last field (Confirm Password Field).

  3. Pass it to Email Config.

Note you will receive the above fields in onSuccess Function as fields param. You can their do some operation like saving to the database.

Last updated

Was this helpful?