chore: fix getting started showing up everytime

This commit is contained in:
Kingkor Roy Tirtho 2024-03-08 23:07:55 +06:00
parent 4a044498a4
commit a248a4b48c
3 changed files with 12 additions and 9 deletions

View File

@ -70,7 +70,6 @@ Future<void> main(List<String> rawArgs) async {
} }
await KVStoreService.initialize(); await KVStoreService.initialize();
KVStoreService.doneGettingStarted = false;
final hiveCacheDir = final hiveCacheDir =
kIsWeb ? null : (await getApplicationSupportDirectory()).path; kIsWeb ? null : (await getApplicationSupportDirectory()).path;

View File

@ -101,9 +101,11 @@ class GettingStartedScreenSupportSection extends HookConsumerWidget {
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: Colors.white, foregroundColor: Colors.white,
), ),
onPressed: () { onPressed: () async {
KVStoreService.doneGettingStarted = true; await KVStoreService.setDoneGettingStarted(true);
context.go("/"); if (context.mounted) {
context.go("/");
}
}, },
), ),
), ),
@ -115,9 +117,11 @@ class GettingStartedScreenSupportSection extends HookConsumerWidget {
backgroundColor: const Color(0xff1db954), backgroundColor: const Color(0xff1db954),
foregroundColor: Colors.white, foregroundColor: Colors.white,
), ),
onPressed: () { onPressed: () async {
KVStoreService.doneGettingStarted = true; await KVStoreService.setDoneGettingStarted(true);
context.push("/login"); if (context.mounted) {
context.push("/login");
}
}, },
), ),
], ],

View File

@ -10,6 +10,6 @@ abstract class KVStoreService {
static bool get doneGettingStarted => static bool get doneGettingStarted =>
sharedPreferences.getBool('doneGettingStarted') ?? false; sharedPreferences.getBool('doneGettingStarted') ?? false;
static set doneGettingStarted(bool value) => static Future<void> setDoneGettingStarted(bool value) async =>
sharedPreferences.setBool('doneGettingStarted', value); await sharedPreferences.setBool('doneGettingStarted', value);
} }