Skip to content

Instantly share code, notes, and snippets.

@yaizudamashii
Last active July 19, 2021 18: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/0a71070e150c80806131807969a97ef0 to your computer and use it in GitHub Desktop.
Save yaizudamashii/0a71070e150c80806131807969a97ef0 to your computer and use it in GitHub Desktop.
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_voice_chat_using_agora/services/shared_preferences_service.dart';
import 'package:state_notifier/state_notifier.dart';
final onboardingViewModelProvider = StateNotifierProvider<OnboardingViewModel, bool>((ref) {
final sharedPreferencesService = ref.watch(sharedPreferencesServiceProvider);
return OnboardingViewModel(sharedPreferencesService);
});
class OnboardingViewModel extends StateNotifier<bool> {
OnboardingViewModel(this.sharedPreferencesService)
: super(sharedPreferencesService.isOnboardingComplete());
final SharedPreferencesService sharedPreferencesService;
Future<void> completeOnboarding() async {
await sharedPreferencesService.setOnboardingComplete();
state = true;
}
bool get isOnboardingComplete => state;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment