authenticateWithDialog method
Future<CarpUser?>
authenticateWithDialog(
- BuildContext context, {
- String? username,
- bool allowClose = false,
Authenticate to this CARP service by showing a modal dialog form for the user to enter his/her username and password.
Returns the authenticated user if successful, null
otherwise.
The context
is required in order to show the login page in the right context.
If the username
is provide, this is shown as default in the form.
In contrast to the other authentication methods, this method does not throws a CarpServiceException if authentication is not successful. Instead the dialog is kept open until authentication is successful, or closed manually by the user.
allowClose
specifies whether the user can close the window.
Implementation
Future<CarpUser?> authenticateWithDialog(
BuildContext context, {
String? username,
bool allowClose = false,
}) async {
if (_app == null) {
throw CarpServiceException(
message:
"CARP Service not initialized. Call 'CarpService().configure()' first.");
}
CarpUser? user = await showDialog<CarpUser>(
context: context,
barrierDismissible: allowClose,
builder: (BuildContext context) => AuthenticationDialog().build(
context,
username: username,
));
return user;
}