- Wallet EnakPoint & EnakCoin: beranda, riwayat, saldo kedaluwarsa, kode bayar, tukar EnakCoin, transfer - PIN (buat, ganti, lupa), outlet, riwayat order, game spin - Halaman community, webview, coming soon, dan ikon menu beranda baru - Redesign Reward Saya: kartu tiket, filter chip, detail kode + QR - Hapus customer point loader, menu, dan checkout lama - Base URL ke enaklo-pos-api.altru.id Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
779 lines
20 KiB
Dart
779 lines
20 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
// coverage:ignore-file
|
|
// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package
|
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
|
|
part of 'auth_bloc.dart';
|
|
|
|
// **************************************************************************
|
|
// FreezedGenerator
|
|
// **************************************************************************
|
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
// dart format off
|
|
T _$identity<T>(T value) => value;
|
|
/// @nodoc
|
|
mixin _$AuthEvent {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthEvent);
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode => runtimeType.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthEvent()';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
class $AuthEventCopyWith<$Res> {
|
|
$AuthEventCopyWith(AuthEvent _, $Res Function(AuthEvent) __);
|
|
}
|
|
|
|
|
|
/// Adds pattern-matching-related methods to [AuthEvent].
|
|
extension AuthEventPatterns on AuthEvent {
|
|
/// A variant of `map` that fallback to returning `orElse`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _FetchCurrentUser value)? fetchCurrentUser,required TResult orElse(),}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _FetchCurrentUser() when fetchCurrentUser != null:
|
|
return fetchCurrentUser(_that);case _:
|
|
return orElse();
|
|
|
|
}
|
|
}
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// Callbacks receives the raw object, upcasted.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case final Subclass2 value:
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _FetchCurrentUser value) fetchCurrentUser,}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _FetchCurrentUser():
|
|
return fetchCurrentUser(_that);case _:
|
|
throw StateError('Unexpected subclass');
|
|
|
|
}
|
|
}
|
|
/// A variant of `map` that fallback to returning `null`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _FetchCurrentUser value)? fetchCurrentUser,}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _FetchCurrentUser() when fetchCurrentUser != null:
|
|
return fetchCurrentUser(_that);case _:
|
|
return null;
|
|
|
|
}
|
|
}
|
|
/// A variant of `when` that fallback to an `orElse` callback.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? fetchCurrentUser,required TResult orElse(),}) {final _that = this;
|
|
switch (_that) {
|
|
case _FetchCurrentUser() when fetchCurrentUser != null:
|
|
return fetchCurrentUser();case _:
|
|
return orElse();
|
|
|
|
}
|
|
}
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// As opposed to `map`, this offers destructuring.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case Subclass2(:final field2):
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() fetchCurrentUser,}) {final _that = this;
|
|
switch (_that) {
|
|
case _FetchCurrentUser():
|
|
return fetchCurrentUser();case _:
|
|
throw StateError('Unexpected subclass');
|
|
|
|
}
|
|
}
|
|
/// A variant of `when` that fallback to returning `null`
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? fetchCurrentUser,}) {final _that = this;
|
|
switch (_that) {
|
|
case _FetchCurrentUser() when fetchCurrentUser != null:
|
|
return fetchCurrentUser();case _:
|
|
return null;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
|
|
|
|
class _FetchCurrentUser implements AuthEvent {
|
|
const _FetchCurrentUser();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _FetchCurrentUser);
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode => runtimeType.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthEvent.fetchCurrentUser()';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @nodoc
|
|
mixin _$AuthState {
|
|
|
|
User get user; AuthStatus get status; Option<AuthFailure> get failureOption; bool get isFetching;
|
|
/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@pragma('vm:prefer-inline')
|
|
$AuthStateCopyWith<AuthState> get copyWith => _$AuthStateCopyWithImpl<AuthState>(this as AuthState, _$identity);
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
final _this = this as AuthState;
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthState&&(identical(other.user, _this.user) || other.user == _this.user)&&(identical(other.status, _this.status) || other.status == _this.status)&&(identical(other.failureOption, _this.failureOption) || other.failureOption == _this.failureOption)&&(identical(other.isFetching, _this.isFetching) || other.isFetching == _this.isFetching));
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode {
|
|
final _this = this as AuthState;
|
|
return Object.hash(runtimeType,_this.user,_this.status,_this.failureOption,_this.isFetching);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
final _this = this as AuthState;
|
|
return 'AuthState(user: ${_this.user}, status: ${_this.status}, failureOption: ${_this.failureOption}, isFetching: ${_this.isFetching})';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract mixin class $AuthStateCopyWith<$Res> {
|
|
factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) _then) = _$AuthStateCopyWithImpl;
|
|
@useResult
|
|
$Res call({
|
|
User user, AuthStatus status, Option<AuthFailure> failureOption, bool isFetching
|
|
});
|
|
|
|
|
|
$UserCopyWith<$Res> get user;$AuthStatusCopyWith<$Res> get status;
|
|
|
|
}
|
|
/// @nodoc
|
|
class _$AuthStateCopyWithImpl<$Res>
|
|
implements $AuthStateCopyWith<$Res> {
|
|
_$AuthStateCopyWithImpl(this._self, this._then);
|
|
|
|
final AuthState _self;
|
|
final $Res Function(AuthState) _then;
|
|
|
|
/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@pragma('vm:prefer-inline') @override $Res call({Object? user = null,Object? status = null,Object? failureOption = null,Object? isFetching = null,}) {
|
|
return _then(AuthState(
|
|
user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
|
as User,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
|
as AuthStatus,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable
|
|
as Option<AuthFailure>,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
));
|
|
}
|
|
/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$UserCopyWith<$Res> get user {
|
|
|
|
return $UserCopyWith<$Res>(_self.user, (value) {
|
|
return _then(_self.copyWith(user: value));
|
|
});
|
|
}/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$AuthStatusCopyWith<$Res> get status {
|
|
|
|
return $AuthStatusCopyWith<$Res>(_self.status, (value) {
|
|
return _then(_self.copyWith(status: value));
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
/// Adds pattern-matching-related methods to [AuthState].
|
|
extension AuthStatePatterns on AuthState {
|
|
/// A variant of `map` that fallback to returning `orElse`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _AuthState value)? $default,{required TResult orElse(),}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _AuthState() when $default != null:
|
|
return $default(_that);case _:
|
|
return orElse();
|
|
|
|
}
|
|
}
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// Callbacks receives the raw object, upcasted.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case final Subclass2 value:
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _AuthState value) $default,){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _AuthState():
|
|
return $default(_that);case _:
|
|
throw StateError('Unexpected subclass');
|
|
|
|
}
|
|
}
|
|
/// A variant of `map` that fallback to returning `null`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _AuthState value)? $default,){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _AuthState() when $default != null:
|
|
return $default(_that);case _:
|
|
return null;
|
|
|
|
}
|
|
}
|
|
/// A variant of `when` that fallback to an `orElse` callback.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( User user, AuthStatus status, Option<AuthFailure> failureOption, bool isFetching)? $default,{required TResult orElse(),}) {final _that = this;
|
|
switch (_that) {
|
|
case _AuthState() when $default != null:
|
|
return $default(_that.user,_that.status,_that.failureOption,_that.isFetching);case _:
|
|
return orElse();
|
|
|
|
}
|
|
}
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// As opposed to `map`, this offers destructuring.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case Subclass2(:final field2):
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( User user, AuthStatus status, Option<AuthFailure> failureOption, bool isFetching) $default,) {final _that = this;
|
|
switch (_that) {
|
|
case _AuthState():
|
|
return $default(_that.user,_that.status,_that.failureOption,_that.isFetching);case _:
|
|
throw StateError('Unexpected subclass');
|
|
|
|
}
|
|
}
|
|
/// A variant of `when` that fallback to returning `null`
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( User user, AuthStatus status, Option<AuthFailure> failureOption, bool isFetching)? $default,) {final _that = this;
|
|
switch (_that) {
|
|
case _AuthState() when $default != null:
|
|
return $default(_that.user,_that.status,_that.failureOption,_that.isFetching);case _:
|
|
return null;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
|
|
|
|
class _AuthState extends AuthState {
|
|
const _AuthState({required this.user, this.status = const AuthStatus.initial(), required this.failureOption, this.isFetching = false}): super._();
|
|
|
|
|
|
@override final User user;
|
|
@override@JsonKey() final AuthStatus status;
|
|
@override final Option<AuthFailure> failureOption;
|
|
@override@JsonKey() final bool isFetching;
|
|
|
|
/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override @JsonKey(includeFromJson: false, includeToJson: false)
|
|
@pragma('vm:prefer-inline')
|
|
_$AuthStateCopyWith<_AuthState> get copyWith => __$AuthStateCopyWithImpl<_AuthState>(this, _$identity);
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _AuthState&&(identical(other.user, user) || other.user == user)&&(identical(other.status, status) || other.status == status)&&(identical(other.failureOption, failureOption) || other.failureOption == failureOption)&&(identical(other.isFetching, isFetching) || other.isFetching == isFetching));
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode {
|
|
return Object.hash(runtimeType,user,status,failureOption,isFetching);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthState(user: $user, status: $status, failureOption: $failureOption, isFetching: $isFetching)';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract mixin class _$AuthStateCopyWith<$Res> implements $AuthStateCopyWith<$Res> {
|
|
factory _$AuthStateCopyWith(_AuthState value, $Res Function(_AuthState) _then) = __$AuthStateCopyWithImpl;
|
|
@override @useResult
|
|
$Res call({
|
|
User user, AuthStatus status, Option<AuthFailure> failureOption, bool isFetching
|
|
});
|
|
|
|
|
|
@override $UserCopyWith<$Res> get user;@override $AuthStatusCopyWith<$Res> get status;
|
|
|
|
}
|
|
/// @nodoc
|
|
class __$AuthStateCopyWithImpl<$Res>
|
|
implements _$AuthStateCopyWith<$Res> {
|
|
__$AuthStateCopyWithImpl(this._self, this._then);
|
|
|
|
final _AuthState _self;
|
|
final $Res Function(_AuthState) _then;
|
|
|
|
/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override @pragma('vm:prefer-inline') $Res call({Object? user = null,Object? status = null,Object? failureOption = null,Object? isFetching = null,}) {
|
|
return _then(_AuthState(
|
|
user: null == user ? _self.user : user // ignore: cast_nullable_to_non_nullable
|
|
as User,status: null == status ? _self.status : status // ignore: cast_nullable_to_non_nullable
|
|
as AuthStatus,failureOption: null == failureOption ? _self.failureOption : failureOption // ignore: cast_nullable_to_non_nullable
|
|
as Option<AuthFailure>,isFetching: null == isFetching ? _self.isFetching : isFetching // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
));
|
|
}
|
|
|
|
/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$UserCopyWith<$Res> get user {
|
|
|
|
return $UserCopyWith<$Res>(_self.user, (value) {
|
|
return _then(_self.copyWith(user: value));
|
|
});
|
|
}/// Create a copy of AuthState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$AuthStatusCopyWith<$Res> get status {
|
|
|
|
return $AuthStatusCopyWith<$Res>(_self.status, (value) {
|
|
return _then(_self.copyWith(status: value));
|
|
});
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
mixin _$AuthStatus {
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is AuthStatus);
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode => runtimeType.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthStatus()';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
class $AuthStatusCopyWith<$Res> {
|
|
$AuthStatusCopyWith(AuthStatus _, $Res Function(AuthStatus) __);
|
|
}
|
|
|
|
|
|
/// Adds pattern-matching-related methods to [AuthStatus].
|
|
extension AuthStatusPatterns on AuthStatus {
|
|
/// A variant of `map` that fallback to returning `orElse`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult maybeMap<TResult extends Object?>({TResult Function( _Authenticated value)? authenticated,TResult Function( _Unauthenticated value)? unauthenticated,TResult Function( _Initial value)? initial,required TResult orElse(),}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _Authenticated() when authenticated != null:
|
|
return authenticated(_that);case _Unauthenticated() when unauthenticated != null:
|
|
return unauthenticated(_that);case _Initial() when initial != null:
|
|
return initial(_that);case _:
|
|
return orElse();
|
|
|
|
}
|
|
}
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// Callbacks receives the raw object, upcasted.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case final Subclass2 value:
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult map<TResult extends Object?>({required TResult Function( _Authenticated value) authenticated,required TResult Function( _Unauthenticated value) unauthenticated,required TResult Function( _Initial value) initial,}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _Authenticated():
|
|
return authenticated(_that);case _Unauthenticated():
|
|
return unauthenticated(_that);case _Initial():
|
|
return initial(_that);}
|
|
}
|
|
/// A variant of `map` that fallback to returning `null`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>({TResult? Function( _Authenticated value)? authenticated,TResult? Function( _Unauthenticated value)? unauthenticated,TResult? Function( _Initial value)? initial,}){
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _Authenticated() when authenticated != null:
|
|
return authenticated(_that);case _Unauthenticated() when unauthenticated != null:
|
|
return unauthenticated(_that);case _Initial() when initial != null:
|
|
return initial(_that);case _:
|
|
return null;
|
|
|
|
}
|
|
}
|
|
/// A variant of `when` that fallback to an `orElse` callback.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>({TResult Function()? authenticated,TResult Function()? unauthenticated,TResult Function()? initial,required TResult orElse(),}) {final _that = this;
|
|
switch (_that) {
|
|
case _Authenticated() when authenticated != null:
|
|
return authenticated();case _Unauthenticated() when unauthenticated != null:
|
|
return unauthenticated();case _Initial() when initial != null:
|
|
return initial();case _:
|
|
return orElse();
|
|
|
|
}
|
|
}
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// As opposed to `map`, this offers destructuring.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case Subclass2(:final field2):
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult when<TResult extends Object?>({required TResult Function() authenticated,required TResult Function() unauthenticated,required TResult Function() initial,}) {final _that = this;
|
|
switch (_that) {
|
|
case _Authenticated():
|
|
return authenticated();case _Unauthenticated():
|
|
return unauthenticated();case _Initial():
|
|
return initial();}
|
|
}
|
|
/// A variant of `when` that fallback to returning `null`
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>({TResult? Function()? authenticated,TResult? Function()? unauthenticated,TResult? Function()? initial,}) {final _that = this;
|
|
switch (_that) {
|
|
case _Authenticated() when authenticated != null:
|
|
return authenticated();case _Unauthenticated() when unauthenticated != null:
|
|
return unauthenticated();case _Initial() when initial != null:
|
|
return initial();case _:
|
|
return null;
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
/// @nodoc
|
|
|
|
|
|
class _Authenticated implements AuthStatus {
|
|
const _Authenticated();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Authenticated);
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode => runtimeType.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthStatus.authenticated()';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @nodoc
|
|
|
|
|
|
class _Unauthenticated implements AuthStatus {
|
|
const _Unauthenticated();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Unauthenticated);
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode => runtimeType.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthStatus.unauthenticated()';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// @nodoc
|
|
|
|
|
|
class _Initial implements AuthStatus {
|
|
const _Initial();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Initial);
|
|
}
|
|
|
|
|
|
@override
|
|
int get hashCode => runtimeType.hashCode;
|
|
|
|
@override
|
|
String toString() {
|
|
return 'AuthStatus.initial()';
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// dart format on
|