Custom Form Fields
For email Sign Up/Sign In you can add/remove form fields.
Addition
Create a field object(Language Field in our case).
Add it to the list of SignUp/SignIn fields.
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).
Get the SignUp/SignIn fields.
Pop the last field (Confirm Password Field).
Pass it to Email Config.
Widget build(BuildContext context) {
final signUpFields = getSignUpFields();
signUpFields.removeLast();
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');
},
),
);
}
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?