rx_shared_preferences 1.1.0 rx_shared_preferences: ^1.1.0 copied to clipboard
Shared preferences with rxdart Stream observation. Reactive shared preferences for Flutter. Reactive stream wrapper around SharedPreferences. Lightweight and easy-to-use.
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() {
/// 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(),
);
}
}