rx_shared_preferences 3.0.0 rx_shared_preferences: ^3.0.0 copied to clipboard
Rxdart streaming shared preferences. Reactive stream rxdart wrapper around SharedPreferences. A stream based wrapper over shared_preferences, allowing reactive key-value storage.
import 'package:example/home.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_provider/flutter_provider.dart';
import 'package:rx_shared_preferences/rx_shared_preferences.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
/// Singleton instance for app
final rxPrefs = RxSharedPreferences(
SharedPreferences.getInstance(),
kReleaseMode ? null : const RxSharedPreferencesDefaultLogger(),
);
runApp(
Provider.value(
rxPrefs,
child: const MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'RxSharedPreferences example',
theme: ThemeData.dark(),
home: const MyHomePage(),
);
}
}