rx_shared_preferences 1.3.3 rx_shared_preferences: ^1.3.3 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:example/loggers.dart';
import 'package:example/rx_prefs_provider.dart';
import 'package:flutter/material.dart';
import 'package:rx_shared_preferences/rx_shared_preferences.dart';
import 'package:shared_preferences/shared_preferences.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
/// Singleton instance for app
final rxPrefs = RxSharedPreferences(
SharedPreferences.getInstance(),
defaultLogger,
);
runApp(
RxPrefsProvider(
rxPrefs: rxPrefs,
child: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Rx Shared Preferences example',
theme: ThemeData.dark(),
home: const MyHomePage(),
);
}
}