Home > database >  Flutter source - Future<String?>? Function(String)
Flutter source - Future<String?>? Function(String)

Time:08-19

I'm new to flutter?

Can someone explain to me what the following line of code means?

typedef RecoverCallback = Future<String?>? Function(String); enter image description here

This line is contained in the auth.dart file of the flutter_login plugin https://github.com/NearHuscarl/flutter_login/blob/master/lib/src/providers/auth.dart

So Function(String) Where is it implemented?

CodePudding user response:

The reason I want to understand the above line of code is because final error = await auth.onRecoverPassword!(auth.email); error = null;

but no mail is sent to auth.email.

CodePudding user response:

typedef RecoverCallback = Future<String?>? Function(String);

It's function-type alias, gives a function type a name that you can use when declaring fields and return types.

As you can see in 45 line of class Auth implementation, that function you need to pass to the constructor of

new Auth(onRecoverPassword: yourFunction);

yourFunction must be a Function that take some String parameter and return Future<String?> or null;

  • Related