feat: upgrade Riverpod 3, go_router 17, google_fonts 8, package_info_plus 9
Migrate StateNotifierProvider/StateNotifier → NotifierProvider/Notifier, StateProvider → NotifierProvider with simple notifier, FamilyAsyncNotifier removed in Riverpod 3 (replaced with constructor-arg pattern), and rename .valueOrNull → .value throughout all providers and screens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,18 +4,15 @@ import 'api_client_provider.dart';
|
||||
|
||||
enum AuthStatus { unknown, authenticated, unauthenticated }
|
||||
|
||||
final authProvider = StateNotifierProvider<AuthNotifier, AuthStatus>((ref) {
|
||||
return AuthNotifier(ref);
|
||||
});
|
||||
final authProvider = NotifierProvider<AuthNotifier, AuthStatus>(AuthNotifier.new);
|
||||
|
||||
class AuthNotifier extends StateNotifier<AuthStatus> {
|
||||
final Ref _ref;
|
||||
|
||||
AuthNotifier(this._ref) : super(AuthStatus.unknown);
|
||||
class AuthNotifier extends Notifier<AuthStatus> {
|
||||
@override
|
||||
AuthStatus build() => AuthStatus.unknown;
|
||||
|
||||
Future<void> verify() async {
|
||||
try {
|
||||
final repo = _ref.read(authRepositoryProvider);
|
||||
final repo = ref.read(authRepositoryProvider);
|
||||
final ok = await repo.verify();
|
||||
state = ok ? AuthStatus.authenticated : AuthStatus.unauthenticated;
|
||||
} catch (_) {
|
||||
@@ -24,14 +21,14 @@ class AuthNotifier extends StateNotifier<AuthStatus> {
|
||||
}
|
||||
|
||||
Future<void> login(String username, String password) async {
|
||||
final repo = _ref.read(authRepositoryProvider);
|
||||
final repo = ref.read(authRepositoryProvider);
|
||||
await repo.login(username, password);
|
||||
state = AuthStatus.authenticated;
|
||||
}
|
||||
|
||||
Future<void> logout() async {
|
||||
try {
|
||||
final repo = _ref.read(authRepositoryProvider);
|
||||
final repo = ref.read(authRepositoryProvider);
|
||||
await repo.logout();
|
||||
} finally {
|
||||
state = AuthStatus.unauthenticated;
|
||||
|
||||
Reference in New Issue
Block a user