Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Example of a service to help abstract the storage of experimental mode on local device
import 'package:firebase_analytics/firebase_analytics.dart';
import 'package:japanese_reading/services/preferences.dart';
class ExperimentalMode {
static final cacheStaleKey = 'cache_stale';
static final experimentalModeKey = 'experimental_mode';
final FirebaseAnalytics analytics;
final Preferences preferences;
get isExperimentalMode => preferences.getBool(experimentalModeKey) ?? false;
void setConfigStale(bool isStale) {
preferences.set(cacheStaleKey, isStale);
bool isConfigStale() => preferences.getBool(cacheStaleKey) ?? false;
void setExperimentalMode(bool experimentalMode) {
final value = experimentalMode ? "true" : "false";
preferences.set(experimentalModeKey, experimentalMode); 'experimental_mode', value: value); 'toggled_experimental_mode', parameters: { 'value': value });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment