From 7e06944e6b3ff450c3d8f3628c5c6a55cefc247d Mon Sep 17 00:00:00 2001 From: Mayank Variya Date: Fri, 8 Nov 2024 15:56:01 +0530 Subject: [PATCH] Fix analyzed error --- data/.flutter-plugins-dependencies | 2 +- data/lib/service/auth/auth_service.dart | 5 +- .../provider/preferences_provider.dart | 63 ++++++++++++------- data/pubspec.yaml | 4 +- .../flow/main/main_screen_state_notifier.dart | 3 +- .../edit_profile/edit_profile_view_model.dart | 3 +- khelo/pubspec.lock | 12 ++-- khelo/pubspec.yaml | 4 +- 8 files changed, 59 insertions(+), 37 deletions(-) diff --git a/data/.flutter-plugins-dependencies b/data/.flutter-plugins-dependencies index 49161e34..cbb57dbb 100644 --- a/data/.flutter-plugins-dependencies +++ b/data/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_messaging","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_messaging","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_messaging","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/mayank/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/mayank/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore_web-4.3.2/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions_web-4.10.2/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth_web-5.13.2/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core_web-2.18.1/","dependencies":[]},{"name":"firebase_messaging_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging_web-3.9.2/","dependencies":["firebase_core_web"]},{"name":"firebase_storage_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage_web-3.10.2/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_messaging","dependencies":["firebase_core","firebase_messaging_web"]},{"name":"firebase_messaging_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_timezone","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-10-22 11:52:42.956224","version":"3.24.3","swift_package_manager_enabled":false} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_messaging","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_messaging","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_android","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_android-2.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"cloud_functions","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions-5.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":true,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_messaging","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging-15.1.3/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":true,"dependencies":[]},{"name":"shared_preferences_foundation","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_foundation-2.5.3/","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":false,"dependencies":[]},{"name":"path_provider_linux","path":"/home/mayank/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[]},{"name":"shared_preferences_linux","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_linux-2.4.1/","native_build":false,"dependencies":["path_provider_linux"]}],"windows":[{"name":"cloud_firestore","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore-5.4.4/","native_build":true,"dependencies":["firebase_core"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","native_build":false,"dependencies":[]},{"name":"firebase_auth","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth-5.3.1/","native_build":true,"dependencies":["firebase_core"]},{"name":"firebase_core","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core-3.6.0/","native_build":true,"dependencies":[]},{"name":"firebase_storage","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage-12.3.2/","native_build":true,"dependencies":["firebase_core"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","native_build":false,"dependencies":[]},{"name":"path_provider_windows","path":"/home/mayank/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[]},{"name":"shared_preferences_windows","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_windows-2.4.1/","native_build":false,"dependencies":["path_provider_windows"]}],"web":[{"name":"cloud_firestore_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_firestore_web-4.3.2/","dependencies":["firebase_core_web"]},{"name":"cloud_functions_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/cloud_functions_web-4.10.2/","dependencies":["firebase_core_web"]},{"name":"device_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/device_info_plus-10.1.2/","dependencies":[]},{"name":"firebase_auth_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_auth_web-5.13.2/","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_core_web-2.18.1/","dependencies":[]},{"name":"firebase_messaging_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_messaging_web-3.9.2/","dependencies":["firebase_core_web"]},{"name":"firebase_storage_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/firebase_storage_web-3.10.2/","dependencies":["firebase_core_web"]},{"name":"flutter_timezone","path":"/home/mayank/.pub-cache/hosted/pub.dev/flutter_timezone-3.0.1/","dependencies":[]},{"name":"package_info_plus","path":"/home/mayank/.pub-cache/hosted/pub.dev/package_info_plus-8.0.2/","dependencies":[]},{"name":"shared_preferences_web","path":"/home/mayank/.pub-cache/hosted/pub.dev/shared_preferences_web-2.4.2/","dependencies":[]}]},"dependencyGraph":[{"name":"cloud_firestore","dependencies":["cloud_firestore_web","firebase_core"]},{"name":"cloud_firestore_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"cloud_functions","dependencies":["cloud_functions_web","firebase_core"]},{"name":"cloud_functions_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"device_info_plus","dependencies":[]},{"name":"firebase_auth","dependencies":["firebase_auth_web","firebase_core"]},{"name":"firebase_auth_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_core","dependencies":["firebase_core_web"]},{"name":"firebase_core_web","dependencies":[]},{"name":"firebase_messaging","dependencies":["firebase_core","firebase_messaging_web"]},{"name":"firebase_messaging_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"firebase_storage","dependencies":["firebase_core","firebase_storage_web"]},{"name":"firebase_storage_web","dependencies":["firebase_core","firebase_core_web"]},{"name":"flutter_timezone","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_foundation","shared_preferences_linux","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_foundation","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]}],"date_created":"2024-11-08 15:14:13.712605","version":"3.24.3","swift_package_manager_enabled":false} \ No newline at end of file diff --git a/data/lib/service/auth/auth_service.dart b/data/lib/service/auth/auth_service.dart index eabb5e39..606fbefb 100644 --- a/data/lib/service/auth/auth_service.dart +++ b/data/lib/service/auth/auth_service.dart @@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart'; import '../../errors/app_error.dart'; import '../../extensions/string_extensions.dart'; import '../../storage/app_preferences.dart'; +import '../../storage/provider/preferences_provider.dart'; import '../user/user_service.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -25,8 +26,8 @@ class AuthService { final FirebaseAuth _auth; final UserService _userService; - final StateController _currentUserNotifier; - final StateController _userSessionNotifier; + final PreferenceNotifier _currentUserNotifier; + final PreferenceNotifier _userSessionNotifier; AuthService( this._auth, diff --git a/data/lib/storage/provider/preferences_provider.dart b/data/lib/storage/provider/preferences_provider.dart index 350b02be..78168f9b 100644 --- a/data/lib/storage/provider/preferences_provider.dart +++ b/data/lib/storage/provider/preferences_provider.dart @@ -2,30 +2,49 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:shared_preferences/shared_preferences.dart'; final sharedPreferencesProvider = - Provider((ref) => throw UnimplementedError()); +Provider((ref) => throw UnimplementedError()); -StateProvider createPrefProvider({ +StateNotifierProvider, T> createPrefProvider({ required String prefKey, required T defaultValue, }) { - return StateProvider((ref) { - final prefs = ref.watch(sharedPreferencesProvider); - final currentValue = prefs.get(prefKey) as T? ?? defaultValue; - ref.listenSelf((prev, curr) { - if (curr == null) { - prefs.remove(prefKey); - } else if (curr is String) { - prefs.setString(prefKey, curr); - } else if (curr is bool) { - prefs.setBool(prefKey, curr); - } else if (curr is int) { - prefs.setInt(prefKey, curr); - } else if (curr is double) { - prefs.setDouble(prefKey, curr); - } else if (curr is List) { - prefs.setStringList(prefKey, curr); - } - }); - return currentValue; - }); + return StateNotifierProvider, T>( + (ref) => PreferenceNotifier( + ref.watch(sharedPreferencesProvider).get(prefKey) as T? ?? defaultValue, + (curr) { + final prefs = ref.watch(sharedPreferencesProvider); + if (curr == null) { + prefs.remove(prefKey); + } else if (curr is String) { + prefs.setString(prefKey, curr); + } else if (curr is bool) { + prefs.setBool(prefKey, curr); + } else if (curr is int) { + prefs.setInt(prefKey, curr); + } else if (curr is double) { + prefs.setDouble(prefKey, curr); + } else if (curr is List) { + prefs.setStringList(prefKey, curr); + } + }, + ), + ); } + +class PreferenceNotifier extends StateNotifier { + Function(T curr)? onUpdate; + + PreferenceNotifier( + super.value, + this.onUpdate, + ); + + @override + set state(T value) { + super.state = value; + onUpdate?.call(value); + } + + @override + T get state => super.state; +} \ No newline at end of file diff --git a/data/pubspec.yaml b/data/pubspec.yaml index 75123484..36ca34fb 100644 --- a/data/pubspec.yaml +++ b/data/pubspec.yaml @@ -40,8 +40,8 @@ dependencies: uuid: ^4.5.1 # state management - flutter_riverpod: 2.5.3 - hooks_riverpod: ^2.5.4 + flutter_riverpod: ^2.6.1 + hooks_riverpod: ^2.6.1 dev_dependencies: flutter_test: diff --git a/khelo/lib/ui/flow/main/main_screen_state_notifier.dart b/khelo/lib/ui/flow/main/main_screen_state_notifier.dart index a6ceb892..c635f28b 100644 --- a/khelo/lib/ui/flow/main/main_screen_state_notifier.dart +++ b/khelo/lib/ui/flow/main/main_screen_state_notifier.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:data/api/user/user_models.dart'; import 'package:data/service/auth/auth_service.dart'; import 'package:data/storage/app_preferences.dart'; +import 'package:data/storage/provider/preferences_provider.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; @@ -20,7 +21,7 @@ final mainScreenStateNotifierProvider = }); class MainScreenStateNotifier extends StateNotifier { - final StateController _lastNotificationPermissionPromptDate; + final PreferenceNotifier _lastNotificationPermissionPromptDate; final UserModel? _currentUser; final AuthService _authService; diff --git a/khelo/lib/ui/flow/settings/edit_profile/edit_profile_view_model.dart b/khelo/lib/ui/flow/settings/edit_profile/edit_profile_view_model.dart index 35928560..4878ab7b 100644 --- a/khelo/lib/ui/flow/settings/edit_profile/edit_profile_view_model.dart +++ b/khelo/lib/ui/flow/settings/edit_profile/edit_profile_view_model.dart @@ -8,6 +8,7 @@ import 'package:data/service/match/match_service.dart'; import 'package:data/service/team/team_service.dart'; import 'package:data/service/user/user_service.dart'; import 'package:data/storage/app_preferences.dart'; +import 'package:data/storage/provider/preferences_provider.dart'; import 'package:data/utils/constant/firebase_storage_constant.dart'; import 'package:firebase_auth/firebase_auth.dart'; import 'package:flutter/material.dart'; @@ -39,7 +40,7 @@ class EditProfileViewNotifier extends StateNotifier { final AuthService _authService; final TeamService _teamService; final MatchService _matchService; - final StateController _userJsonController; + final PreferenceNotifier _userJsonController; EditProfileViewNotifier( this._fileUploadService, diff --git a/khelo/pubspec.lock b/khelo/pubspec.lock index 3e92fc2e..767ae161 100644 --- a/khelo/pubspec.lock +++ b/khelo/pubspec.lock @@ -675,10 +675,10 @@ packages: dependency: "direct main" description: name: flutter_riverpod - sha256: "711d916456563f715bde1e139d7cfdca009f8264befab3ac9f8ded8b6ec26405" + sha256: "9532ee6db4a943a1ed8383072a2e3eeda041db5657cdf6d2acecf3c21ecbe7e1" url: "https://pub.dev" source: hosted - version: "2.5.3" + version: "2.6.1" flutter_svg: dependency: "direct main" description: @@ -781,10 +781,10 @@ packages: dependency: "direct main" description: name: hooks_riverpod - sha256: "534ca8af331235f700f3916a74e4579cdfdd708e2fbed342fc8aa969d41a7af0" + sha256: "70bba33cfc5670c84b796e6929c54b8bc5be7d0fe15bb28c2560500b9ad06966" url: "https://pub.dev" source: hosted - version: "2.5.4" + version: "2.6.1" hotreloader: dependency: transitive description: @@ -1261,10 +1261,10 @@ packages: dependency: transitive description: name: riverpod - sha256: c86fedfb45dd1da98ee6493dd9374325cdf494e7d523ebfb0c387eecc5f7b5c9 + sha256: "59062512288d3056b2321804332a13ffdd1bf16df70dcc8e506e411280a72959" url: "https://pub.dev" source: hosted - version: "2.5.3" + version: "2.6.1" riverpod_analyzer_utils: dependency: transitive description: diff --git a/khelo/pubspec.yaml b/khelo/pubspec.yaml index 5662069f..b8fd7566 100644 --- a/khelo/pubspec.yaml +++ b/khelo/pubspec.yaml @@ -75,8 +75,8 @@ dependencies: firebase_messaging: ^15.1.3 # state management - flutter_riverpod: 2.5.3 - hooks_riverpod: 2.5.4 + flutter_riverpod: ^2.6.1 + hooks_riverpod: ^2.6.1 # navigation go_router: ^14.3.0