I am currently using flutter_login 3.1.0 in my application. During the process of user signing up, it is required that he assigns himself a username, the application is supposed to check whether the username that is typed in is taken or not from Firebase Firestore and display it to the user.
@override
Widget build(BuildContext context) {
return FlutterLogin(
// irrelevant code removed
additionalSignupFields: [
UserFormField(
keyName: 'username',
displayName: 'Username',
icon: const Icon(FontAwesomeIcons.at),
fieldValidator: (value) async { // error 'Cant assign async function to function'
return await DatabaseService.validateUsername(value);
},
),
]
)
}
The function assigned to fieldValidator has to be async
because getting data from firestore always returns a Future
.
People have told me to use FutureBuilder or StreamBuilder, I have tried and failed to achieve the functionality. It would great if code is provided rather than just an explanation