mirror of
https://github.com/koloideal/Casha.git
synced 2026-08-08 17:51:14 +03:00
step
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import '../../features/dashboard/provider.dart';
|
||||
import '../services/onboarding_service.dart';
|
||||
|
||||
final onboardingServiceProvider = Provider<OnboardingService>((ref) {
|
||||
final prefs = ref.watch(sharedPreferencesProvider);
|
||||
return OnboardingService(prefs);
|
||||
});
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class OnboardingService {
|
||||
static const _key = 'onboarding_completed';
|
||||
static bool _shownInSession = false;
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
OnboardingService(this._prefs);
|
||||
|
||||
bool get shouldShowOnboarding {
|
||||
if (kDebugMode) {
|
||||
return !_shownInSession;
|
||||
}
|
||||
return !(_prefs.getBool(_key) ?? false);
|
||||
}
|
||||
|
||||
Future<void> completeOnboarding() async {
|
||||
_shownInSession = true;
|
||||
if (!kDebugMode) {
|
||||
await _prefs.setBool(_key, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user