fix settings
This commit is contained in:
145
lib/features/auth/presentation/providers/auth_providers.dart
Normal file
145
lib/features/auth/presentation/providers/auth_providers.dart
Normal file
@@ -0,0 +1,145 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import '../../../../core/network/dio_client.dart';
|
||||
import '../../../../core/network/network_info.dart';
|
||||
import '../../../../core/providers/network_providers.dart';
|
||||
import '../../../../shared/presentation/providers/app_providers.dart' hide secureStorageProvider;
|
||||
import '../../../../shared/domain/usecases/usecase.dart';
|
||||
import '../../data/datasources/auth_local_datasource.dart';
|
||||
import '../../data/datasources/auth_remote_datasource.dart';
|
||||
import '../../data/repositories/auth_repository_impl.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
import '../../domain/repositories/auth_repository.dart';
|
||||
import '../../domain/usecases/get_current_user_usecase.dart';
|
||||
import '../../domain/usecases/login_usecase.dart';
|
||||
import '../../domain/usecases/logout_usecase.dart';
|
||||
import 'auth_state.dart';
|
||||
|
||||
part 'auth_providers.g.dart';
|
||||
|
||||
// Data sources
|
||||
@riverpod
|
||||
AuthRemoteDataSource authRemoteDataSource(Ref ref) {
|
||||
final dioClient = ref.watch(dioClientProvider);
|
||||
return AuthRemoteDataSourceImpl(dioClient: dioClient);
|
||||
}
|
||||
|
||||
@riverpod
|
||||
AuthLocalDataSource authLocalDataSource(Ref ref) {
|
||||
final secureStorage = ref.watch(secureStorageProvider);
|
||||
return AuthLocalDataSourceImpl(secureStorage: secureStorage);
|
||||
}
|
||||
|
||||
// Repository
|
||||
@riverpod
|
||||
AuthRepository authRepository(Ref ref) {
|
||||
final remoteDataSource = ref.watch(authRemoteDataSourceProvider);
|
||||
final localDataSource = ref.watch(authLocalDataSourceProvider);
|
||||
final networkInfo = ref.watch(networkInfoProvider);
|
||||
|
||||
return AuthRepositoryImpl(
|
||||
remoteDataSource: remoteDataSource,
|
||||
localDataSource: localDataSource,
|
||||
networkInfo: networkInfo,
|
||||
);
|
||||
}
|
||||
|
||||
// Use cases
|
||||
@riverpod
|
||||
LoginUseCase loginUseCase(Ref ref) {
|
||||
final repository = ref.watch(authRepositoryProvider);
|
||||
return LoginUseCase(repository);
|
||||
}
|
||||
|
||||
@riverpod
|
||||
LogoutUseCase logoutUseCase(Ref ref) {
|
||||
final repository = ref.watch(authRepositoryProvider);
|
||||
return LogoutUseCase(repository);
|
||||
}
|
||||
|
||||
@riverpod
|
||||
GetCurrentUserUseCase getCurrentUserUseCase(Ref ref) {
|
||||
final repository = ref.watch(authRepositoryProvider);
|
||||
return GetCurrentUserUseCase(repository);
|
||||
}
|
||||
|
||||
// Auth state notifier
|
||||
@riverpod
|
||||
class AuthNotifier extends _$AuthNotifier {
|
||||
@override
|
||||
AuthState build() {
|
||||
// Check for cached user on startup
|
||||
_checkAuthStatus();
|
||||
return const AuthState.initial();
|
||||
}
|
||||
|
||||
Future<void> _checkAuthStatus() async {
|
||||
final getCurrentUser = ref.read(getCurrentUserUseCaseProvider);
|
||||
final result = await getCurrentUser(const NoParams());
|
||||
|
||||
result.fold(
|
||||
(failure) => state = AuthState.unauthenticated(failure.message),
|
||||
(user) {
|
||||
if (user != null) {
|
||||
state = AuthState.authenticated(user);
|
||||
} else {
|
||||
state = const AuthState.unauthenticated();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> login({
|
||||
required String email,
|
||||
required String password,
|
||||
}) async {
|
||||
state = const AuthState.loading();
|
||||
|
||||
final loginUseCase = ref.read(loginUseCaseProvider);
|
||||
final params = LoginParams(email: email, password: password);
|
||||
final result = await loginUseCase(params);
|
||||
|
||||
result.fold(
|
||||
(failure) => state = AuthState.error(failure.message),
|
||||
(user) => state = AuthState.authenticated(user),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
state = const AuthState.loading();
|
||||
|
||||
final logoutUseCase = ref.read(logoutUseCaseProvider);
|
||||
final result = await logoutUseCase(const NoParams());
|
||||
|
||||
result.fold(
|
||||
(failure) => state = AuthState.error(failure.message),
|
||||
(_) => state = const AuthState.unauthenticated(),
|
||||
);
|
||||
}
|
||||
|
||||
void clearError() {
|
||||
if (state is AuthStateError) {
|
||||
state = const AuthState.unauthenticated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Current user provider
|
||||
@riverpod
|
||||
User? currentUser(Ref ref) {
|
||||
final authState = ref.watch(authNotifierProvider);
|
||||
return authState.maybeWhen(
|
||||
authenticated: (user) => user,
|
||||
orElse: () => null,
|
||||
);
|
||||
}
|
||||
|
||||
// Is authenticated provider
|
||||
@riverpod
|
||||
bool isAuthenticated(Ref ref) {
|
||||
final authState = ref.watch(authNotifierProvider);
|
||||
return authState.maybeWhen(
|
||||
authenticated: (_) => true,
|
||||
orElse: () => false,
|
||||
);
|
||||
}
|
||||
150
lib/features/auth/presentation/providers/auth_providers.g.dart
Normal file
150
lib/features/auth/presentation/providers/auth_providers.g.dart
Normal file
@@ -0,0 +1,150 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'auth_providers.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// RiverpodGenerator
|
||||
// **************************************************************************
|
||||
|
||||
String _$authRemoteDataSourceHash() =>
|
||||
r'e1e2164defcfc3905e9fb8e75e346817a6e0bf73';
|
||||
|
||||
/// See also [authRemoteDataSource].
|
||||
@ProviderFor(authRemoteDataSource)
|
||||
final authRemoteDataSourceProvider =
|
||||
AutoDisposeProvider<AuthRemoteDataSource>.internal(
|
||||
authRemoteDataSource,
|
||||
name: r'authRemoteDataSourceProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$authRemoteDataSourceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef AuthRemoteDataSourceRef = AutoDisposeProviderRef<AuthRemoteDataSource>;
|
||||
String _$authLocalDataSourceHash() =>
|
||||
r'dfab2fdd71de815f93c16ab9e234bd2d0885d2f4';
|
||||
|
||||
/// See also [authLocalDataSource].
|
||||
@ProviderFor(authLocalDataSource)
|
||||
final authLocalDataSourceProvider =
|
||||
AutoDisposeProvider<AuthLocalDataSource>.internal(
|
||||
authLocalDataSource,
|
||||
name: r'authLocalDataSourceProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$authLocalDataSourceHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef AuthLocalDataSourceRef = AutoDisposeProviderRef<AuthLocalDataSource>;
|
||||
String _$authRepositoryHash() => r'8ce22ed16336f42a50e8266fbafbdbd7db71d613';
|
||||
|
||||
/// See also [authRepository].
|
||||
@ProviderFor(authRepository)
|
||||
final authRepositoryProvider = AutoDisposeProvider<AuthRepository>.internal(
|
||||
authRepository,
|
||||
name: r'authRepositoryProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$authRepositoryHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef AuthRepositoryRef = AutoDisposeProviderRef<AuthRepository>;
|
||||
String _$loginUseCaseHash() => r'cbfd4200f40c132516f20f942ae9d825a31e2515';
|
||||
|
||||
/// See also [loginUseCase].
|
||||
@ProviderFor(loginUseCase)
|
||||
final loginUseCaseProvider = AutoDisposeProvider<LoginUseCase>.internal(
|
||||
loginUseCase,
|
||||
name: r'loginUseCaseProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$loginUseCaseHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef LoginUseCaseRef = AutoDisposeProviderRef<LoginUseCase>;
|
||||
String _$logoutUseCaseHash() => r'67224f00aebb158eab2aba2c4398e98150dd958c';
|
||||
|
||||
/// See also [logoutUseCase].
|
||||
@ProviderFor(logoutUseCase)
|
||||
final logoutUseCaseProvider = AutoDisposeProvider<LogoutUseCase>.internal(
|
||||
logoutUseCase,
|
||||
name: r'logoutUseCaseProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$logoutUseCaseHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef LogoutUseCaseRef = AutoDisposeProviderRef<LogoutUseCase>;
|
||||
String _$getCurrentUserUseCaseHash() =>
|
||||
r'1e9d6222283b80c2b6fc6ed8c89f4130614c0a11';
|
||||
|
||||
/// See also [getCurrentUserUseCase].
|
||||
@ProviderFor(getCurrentUserUseCase)
|
||||
final getCurrentUserUseCaseProvider =
|
||||
AutoDisposeProvider<GetCurrentUserUseCase>.internal(
|
||||
getCurrentUserUseCase,
|
||||
name: r'getCurrentUserUseCaseProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$getCurrentUserUseCaseHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef GetCurrentUserUseCaseRef
|
||||
= AutoDisposeProviderRef<GetCurrentUserUseCase>;
|
||||
String _$currentUserHash() => r'a5dbfda090aa4a2784b934352ff00cf3c751332b';
|
||||
|
||||
/// See also [currentUser].
|
||||
@ProviderFor(currentUser)
|
||||
final currentUserProvider = AutoDisposeProvider<User?>.internal(
|
||||
currentUser,
|
||||
name: r'currentUserProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$currentUserHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef CurrentUserRef = AutoDisposeProviderRef<User?>;
|
||||
String _$isAuthenticatedHash() => r'0f8559d2c47c9554b3c1b9643ed0c2bf1cb18727';
|
||||
|
||||
/// See also [isAuthenticated].
|
||||
@ProviderFor(isAuthenticated)
|
||||
final isAuthenticatedProvider = AutoDisposeProvider<bool>.internal(
|
||||
isAuthenticated,
|
||||
name: r'isAuthenticatedProvider',
|
||||
debugGetCreateSourceHash: const bool.fromEnvironment('dart.vm.product')
|
||||
? null
|
||||
: _$isAuthenticatedHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef IsAuthenticatedRef = AutoDisposeProviderRef<bool>;
|
||||
String _$authNotifierHash() => r'e97041b6776589adb6e6d424d2ebbb7bc837cb5b';
|
||||
|
||||
/// See also [AuthNotifier].
|
||||
@ProviderFor(AuthNotifier)
|
||||
final authNotifierProvider =
|
||||
AutoDisposeNotifierProvider<AuthNotifier, AuthState>.internal(
|
||||
AuthNotifier.new,
|
||||
name: r'authNotifierProvider',
|
||||
debugGetCreateSourceHash:
|
||||
const bool.fromEnvironment('dart.vm.product') ? null : _$authNotifierHash,
|
||||
dependencies: null,
|
||||
allTransitiveDependencies: null,
|
||||
);
|
||||
|
||||
typedef _$AuthNotifier = AutoDisposeNotifier<AuthState>;
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: subtype_of_sealed_class, invalid_use_of_internal_member, invalid_use_of_visible_for_testing_member
|
||||
13
lib/features/auth/presentation/providers/auth_state.dart
Normal file
13
lib/features/auth/presentation/providers/auth_state.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import '../../domain/entities/user.dart';
|
||||
|
||||
part 'auth_state.freezed.dart';
|
||||
|
||||
@freezed
|
||||
class AuthState with _$AuthState {
|
||||
const factory AuthState.initial() = AuthStateInitial;
|
||||
const factory AuthState.loading() = AuthStateLoading;
|
||||
const factory AuthState.authenticated(User user) = AuthStateAuthenticated;
|
||||
const factory AuthState.unauthenticated([String? message]) = AuthStateUnauthenticated;
|
||||
const factory AuthState.error(String message) = AuthStateError;
|
||||
}
|
||||
794
lib/features/auth/presentation/providers/auth_state.freezed.dart
Normal file
794
lib/features/auth/presentation/providers/auth_state.freezed.dart
Normal file
@@ -0,0 +1,794 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// 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_state.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models');
|
||||
|
||||
/// @nodoc
|
||||
mixin _$AuthState {
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(User user) authenticated,
|
||||
required TResult Function(String? message) unauthenticated,
|
||||
required TResult Function(String message) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(User user)? authenticated,
|
||||
TResult? Function(String? message)? unauthenticated,
|
||||
TResult? Function(String message)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(User user)? authenticated,
|
||||
TResult Function(String? message)? unauthenticated,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(AuthStateInitial value) initial,
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateAuthenticated value) authenticated,
|
||||
required TResult Function(AuthStateUnauthenticated value) unauthenticated,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(AuthStateInitial value)? initial,
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult? Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(AuthStateInitial value)? initial,
|
||||
TResult Function(AuthStateLoading value)? loading,
|
||||
TResult Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $AuthStateCopyWith<$Res> {
|
||||
factory $AuthStateCopyWith(AuthState value, $Res Function(AuthState) then) =
|
||||
_$AuthStateCopyWithImpl<$Res, AuthState>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$AuthStateCopyWithImpl<$Res, $Val extends AuthState>
|
||||
implements $AuthStateCopyWith<$Res> {
|
||||
_$AuthStateCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateInitialImplCopyWith<$Res> {
|
||||
factory _$$AuthStateInitialImplCopyWith(_$AuthStateInitialImpl value,
|
||||
$Res Function(_$AuthStateInitialImpl) then) =
|
||||
__$$AuthStateInitialImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateInitialImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateInitialImpl>
|
||||
implements _$$AuthStateInitialImplCopyWith<$Res> {
|
||||
__$$AuthStateInitialImplCopyWithImpl(_$AuthStateInitialImpl _value,
|
||||
$Res Function(_$AuthStateInitialImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AuthStateInitialImpl implements AuthStateInitial {
|
||||
const _$AuthStateInitialImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthState.initial()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$AuthStateInitialImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(User user) authenticated,
|
||||
required TResult Function(String? message) unauthenticated,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return initial();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(User user)? authenticated,
|
||||
TResult? Function(String? message)? unauthenticated,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return initial?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(User user)? authenticated,
|
||||
TResult Function(String? message)? unauthenticated,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(AuthStateInitial value) initial,
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateAuthenticated value) authenticated,
|
||||
required TResult Function(AuthStateUnauthenticated value) unauthenticated,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) {
|
||||
return initial(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(AuthStateInitial value)? initial,
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult? Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) {
|
||||
return initial?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(AuthStateInitial value)? initial,
|
||||
TResult Function(AuthStateLoading value)? loading,
|
||||
TResult Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (initial != null) {
|
||||
return initial(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AuthStateInitial implements AuthState {
|
||||
const factory AuthStateInitial() = _$AuthStateInitialImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateLoadingImplCopyWith<$Res> {
|
||||
factory _$$AuthStateLoadingImplCopyWith(_$AuthStateLoadingImpl value,
|
||||
$Res Function(_$AuthStateLoadingImpl) then) =
|
||||
__$$AuthStateLoadingImplCopyWithImpl<$Res>;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateLoadingImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateLoadingImpl>
|
||||
implements _$$AuthStateLoadingImplCopyWith<$Res> {
|
||||
__$$AuthStateLoadingImplCopyWithImpl(_$AuthStateLoadingImpl _value,
|
||||
$Res Function(_$AuthStateLoadingImpl) _then)
|
||||
: super(_value, _then);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AuthStateLoadingImpl implements AuthStateLoading {
|
||||
const _$AuthStateLoadingImpl();
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthState.loading()';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType && other is _$AuthStateLoadingImpl);
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => runtimeType.hashCode;
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(User user) authenticated,
|
||||
required TResult Function(String? message) unauthenticated,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return loading();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(User user)? authenticated,
|
||||
TResult? Function(String? message)? unauthenticated,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return loading?.call();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(User user)? authenticated,
|
||||
TResult Function(String? message)? unauthenticated,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading();
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(AuthStateInitial value) initial,
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateAuthenticated value) authenticated,
|
||||
required TResult Function(AuthStateUnauthenticated value) unauthenticated,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) {
|
||||
return loading(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(AuthStateInitial value)? initial,
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult? Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) {
|
||||
return loading?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(AuthStateInitial value)? initial,
|
||||
TResult Function(AuthStateLoading value)? loading,
|
||||
TResult Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (loading != null) {
|
||||
return loading(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AuthStateLoading implements AuthState {
|
||||
const factory AuthStateLoading() = _$AuthStateLoadingImpl;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateAuthenticatedImplCopyWith<$Res> {
|
||||
factory _$$AuthStateAuthenticatedImplCopyWith(
|
||||
_$AuthStateAuthenticatedImpl value,
|
||||
$Res Function(_$AuthStateAuthenticatedImpl) then) =
|
||||
__$$AuthStateAuthenticatedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({User user});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateAuthenticatedImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateAuthenticatedImpl>
|
||||
implements _$$AuthStateAuthenticatedImplCopyWith<$Res> {
|
||||
__$$AuthStateAuthenticatedImplCopyWithImpl(
|
||||
_$AuthStateAuthenticatedImpl _value,
|
||||
$Res Function(_$AuthStateAuthenticatedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? user = null,
|
||||
}) {
|
||||
return _then(_$AuthStateAuthenticatedImpl(
|
||||
null == user
|
||||
? _value.user
|
||||
: user // ignore: cast_nullable_to_non_nullable
|
||||
as User,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AuthStateAuthenticatedImpl implements AuthStateAuthenticated {
|
||||
const _$AuthStateAuthenticatedImpl(this.user);
|
||||
|
||||
@override
|
||||
final User user;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthState.authenticated(user: $user)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthStateAuthenticatedImpl &&
|
||||
(identical(other.user, user) || other.user == user));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, user);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthStateAuthenticatedImplCopyWith<_$AuthStateAuthenticatedImpl>
|
||||
get copyWith => __$$AuthStateAuthenticatedImplCopyWithImpl<
|
||||
_$AuthStateAuthenticatedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(User user) authenticated,
|
||||
required TResult Function(String? message) unauthenticated,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return authenticated(user);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(User user)? authenticated,
|
||||
TResult? Function(String? message)? unauthenticated,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return authenticated?.call(user);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(User user)? authenticated,
|
||||
TResult Function(String? message)? unauthenticated,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (authenticated != null) {
|
||||
return authenticated(user);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(AuthStateInitial value) initial,
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateAuthenticated value) authenticated,
|
||||
required TResult Function(AuthStateUnauthenticated value) unauthenticated,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) {
|
||||
return authenticated(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(AuthStateInitial value)? initial,
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult? Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) {
|
||||
return authenticated?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(AuthStateInitial value)? initial,
|
||||
TResult Function(AuthStateLoading value)? loading,
|
||||
TResult Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (authenticated != null) {
|
||||
return authenticated(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AuthStateAuthenticated implements AuthState {
|
||||
const factory AuthStateAuthenticated(final User user) =
|
||||
_$AuthStateAuthenticatedImpl;
|
||||
|
||||
User get user;
|
||||
@JsonKey(ignore: true)
|
||||
_$$AuthStateAuthenticatedImplCopyWith<_$AuthStateAuthenticatedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateUnauthenticatedImplCopyWith<$Res> {
|
||||
factory _$$AuthStateUnauthenticatedImplCopyWith(
|
||||
_$AuthStateUnauthenticatedImpl value,
|
||||
$Res Function(_$AuthStateUnauthenticatedImpl) then) =
|
||||
__$$AuthStateUnauthenticatedImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String? message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateUnauthenticatedImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateUnauthenticatedImpl>
|
||||
implements _$$AuthStateUnauthenticatedImplCopyWith<$Res> {
|
||||
__$$AuthStateUnauthenticatedImplCopyWithImpl(
|
||||
_$AuthStateUnauthenticatedImpl _value,
|
||||
$Res Function(_$AuthStateUnauthenticatedImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = freezed,
|
||||
}) {
|
||||
return _then(_$AuthStateUnauthenticatedImpl(
|
||||
freezed == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AuthStateUnauthenticatedImpl implements AuthStateUnauthenticated {
|
||||
const _$AuthStateUnauthenticatedImpl([this.message]);
|
||||
|
||||
@override
|
||||
final String? message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthState.unauthenticated(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthStateUnauthenticatedImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthStateUnauthenticatedImplCopyWith<_$AuthStateUnauthenticatedImpl>
|
||||
get copyWith => __$$AuthStateUnauthenticatedImplCopyWithImpl<
|
||||
_$AuthStateUnauthenticatedImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(User user) authenticated,
|
||||
required TResult Function(String? message) unauthenticated,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return unauthenticated(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(User user)? authenticated,
|
||||
TResult? Function(String? message)? unauthenticated,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return unauthenticated?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(User user)? authenticated,
|
||||
TResult Function(String? message)? unauthenticated,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (unauthenticated != null) {
|
||||
return unauthenticated(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(AuthStateInitial value) initial,
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateAuthenticated value) authenticated,
|
||||
required TResult Function(AuthStateUnauthenticated value) unauthenticated,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) {
|
||||
return unauthenticated(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(AuthStateInitial value)? initial,
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult? Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) {
|
||||
return unauthenticated?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(AuthStateInitial value)? initial,
|
||||
TResult Function(AuthStateLoading value)? loading,
|
||||
TResult Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (unauthenticated != null) {
|
||||
return unauthenticated(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AuthStateUnauthenticated implements AuthState {
|
||||
const factory AuthStateUnauthenticated([final String? message]) =
|
||||
_$AuthStateUnauthenticatedImpl;
|
||||
|
||||
String? get message;
|
||||
@JsonKey(ignore: true)
|
||||
_$$AuthStateUnauthenticatedImplCopyWith<_$AuthStateUnauthenticatedImpl>
|
||||
get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$AuthStateErrorImplCopyWith<$Res> {
|
||||
factory _$$AuthStateErrorImplCopyWith(_$AuthStateErrorImpl value,
|
||||
$Res Function(_$AuthStateErrorImpl) then) =
|
||||
__$$AuthStateErrorImplCopyWithImpl<$Res>;
|
||||
@useResult
|
||||
$Res call({String message});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$AuthStateErrorImplCopyWithImpl<$Res>
|
||||
extends _$AuthStateCopyWithImpl<$Res, _$AuthStateErrorImpl>
|
||||
implements _$$AuthStateErrorImplCopyWith<$Res> {
|
||||
__$$AuthStateErrorImplCopyWithImpl(
|
||||
_$AuthStateErrorImpl _value, $Res Function(_$AuthStateErrorImpl) _then)
|
||||
: super(_value, _then);
|
||||
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? message = null,
|
||||
}) {
|
||||
return _then(_$AuthStateErrorImpl(
|
||||
null == message
|
||||
? _value.message
|
||||
: message // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
|
||||
class _$AuthStateErrorImpl implements AuthStateError {
|
||||
const _$AuthStateErrorImpl(this.message);
|
||||
|
||||
@override
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AuthState.error(message: $message)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$AuthStateErrorImpl &&
|
||||
(identical(other.message, message) || other.message == message));
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, message);
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$AuthStateErrorImplCopyWith<_$AuthStateErrorImpl> get copyWith =>
|
||||
__$$AuthStateErrorImplCopyWithImpl<_$AuthStateErrorImpl>(
|
||||
this, _$identity);
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult when<TResult extends Object?>({
|
||||
required TResult Function() initial,
|
||||
required TResult Function() loading,
|
||||
required TResult Function(User user) authenticated,
|
||||
required TResult Function(String? message) unauthenticated,
|
||||
required TResult Function(String message) error,
|
||||
}) {
|
||||
return error(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? whenOrNull<TResult extends Object?>({
|
||||
TResult? Function()? initial,
|
||||
TResult? Function()? loading,
|
||||
TResult? Function(User user)? authenticated,
|
||||
TResult? Function(String? message)? unauthenticated,
|
||||
TResult? Function(String message)? error,
|
||||
}) {
|
||||
return error?.call(message);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeWhen<TResult extends Object?>({
|
||||
TResult Function()? initial,
|
||||
TResult Function()? loading,
|
||||
TResult Function(User user)? authenticated,
|
||||
TResult Function(String? message)? unauthenticated,
|
||||
TResult Function(String message)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(message);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult map<TResult extends Object?>({
|
||||
required TResult Function(AuthStateInitial value) initial,
|
||||
required TResult Function(AuthStateLoading value) loading,
|
||||
required TResult Function(AuthStateAuthenticated value) authenticated,
|
||||
required TResult Function(AuthStateUnauthenticated value) unauthenticated,
|
||||
required TResult Function(AuthStateError value) error,
|
||||
}) {
|
||||
return error(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult? mapOrNull<TResult extends Object?>({
|
||||
TResult? Function(AuthStateInitial value)? initial,
|
||||
TResult? Function(AuthStateLoading value)? loading,
|
||||
TResult? Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult? Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult? Function(AuthStateError value)? error,
|
||||
}) {
|
||||
return error?.call(this);
|
||||
}
|
||||
|
||||
@override
|
||||
@optionalTypeArgs
|
||||
TResult maybeMap<TResult extends Object?>({
|
||||
TResult Function(AuthStateInitial value)? initial,
|
||||
TResult Function(AuthStateLoading value)? loading,
|
||||
TResult Function(AuthStateAuthenticated value)? authenticated,
|
||||
TResult Function(AuthStateUnauthenticated value)? unauthenticated,
|
||||
TResult Function(AuthStateError value)? error,
|
||||
required TResult orElse(),
|
||||
}) {
|
||||
if (error != null) {
|
||||
return error(this);
|
||||
}
|
||||
return orElse();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AuthStateError implements AuthState {
|
||||
const factory AuthStateError(final String message) = _$AuthStateErrorImpl;
|
||||
|
||||
String get message;
|
||||
@JsonKey(ignore: true)
|
||||
_$$AuthStateErrorImplCopyWith<_$AuthStateErrorImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
Reference in New Issue
Block a user