maybeWhen<TResult extends Object?> method
- @optionalTypeArgs
- TResult $default(
- String id,
- String name,
- String email,
- bool emailVerified,
- String? image,
- DateTime? createdAt,
- DateTime? updatedAt,
- bool twoFactorEnabled,
- String? username,
- String? displayUsername,
- bool isAnonymous,
- String? phoneNumber,
- bool phoneNumberVerified,
- String? role,
- bool banned,
- String? banReason,
- DateTime? banExpires,
- required TResult orElse(),
A variant of when that fallback to an orElse callback.
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return orElse();
}
Implementation
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String name, String email, bool emailVerified, String? image, DateTime? createdAt, DateTime? updatedAt, bool twoFactorEnabled, String? username, String? displayUsername, bool isAnonymous, String? phoneNumber, bool phoneNumberVerified, String? role, bool banned, String? banReason, DateTime? banExpires)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _User() when $default != null:
return $default(_that.id,_that.name,_that.email,_that.emailVerified,_that.image,_that.createdAt,_that.updatedAt,_that.twoFactorEnabled,_that.username,_that.displayUsername,_that.isAnonymous,_that.phoneNumber,_that.phoneNumberVerified,_that.role,_that.banned,_that.banReason,_that.banExpires);case _:
return orElse();
}
}