Skip to content

Instantly share code, notes, and snippets.

@yaizudamashii
Created April 6, 2021 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yaizudamashii/bcae7d66d6a8af597054024e59eaeb15 to your computer and use it in GitHub Desktop.
Save yaizudamashii/bcae7d66d6a8af597054024e59eaeb15 to your computer and use it in GitHub Desktop.
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:shared_preferences/shared_preferences.dart';
final sharedPreferencesServiceProvider = Provider<SharedPreferencesService>((ref) => throw UnimplementedError());
class SharedPreferencesService {
SharedPreferencesService(this.sharedPreferences);
final SharedPreferences sharedPreferences;
static const onboardingCompleteKey = 'onboardingComplete';
Future<void> setOnboardingComplete() async {
await sharedPreferences.setBool(onboardingCompleteKey, true);
}
bool isOnboardingComplete() =>
sharedPreferences.getBool(onboardingCompleteKey) ?? false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment