@@ -7,13 +7,13 @@ import 'package:flutter_provider/flutter_provider.dart';
77import 'package:rx_shared_preferences/rx_shared_preferences.dart' ;
88import 'package:rxdart_ext/rxdart_ext.dart' ;
99
10- const key = 'com.hoc.list' ;
10+ const listKey = 'com.hoc.list' ;
1111
1212class MyHomePage extends StatefulWidget {
13- const MyHomePage ({Key ? key}) : super ( key: key );
13+ const MyHomePage ({super . key} );
1414
1515 @override
16- _MyHomePageState createState () => _MyHomePageState ();
16+ State < MyHomePage > createState () => _MyHomePageState ();
1717}
1818
1919class _MyHomePageState extends State <MyHomePage > {
@@ -23,7 +23,7 @@ class _MyHomePageState extends State<MyHomePage> {
2323 late final StateStream <ViewState > list$ = controller.stream
2424 .startWith (null )
2525 .switchMap ((_) => context.rxPrefs
26- .getStringListStream (key )
26+ .getStringListStream (listKey )
2727 .map ((list) => ViewState .success (list ?? const []))
2828 .onErrorReturnWith ((e, s) => ViewState .failure (e, s)))
2929 .debug (identifier: '<<STATE>>' , log: debugPrint)
@@ -146,6 +146,7 @@ extension BuildContextX on BuildContext {
146146 }
147147}
148148
149+ @immutable
149150class ViewState {
150151 final List <String > items;
151152 final bool isLoading;
@@ -155,7 +156,7 @@ class ViewState {
155156
156157 const ViewState ._(this .items, this .isLoading, this .error);
157158
158- ViewState .success (List <String > items) : this ._(items, false , null );
159+ const ViewState .success (List <String > items) : this ._(items, false , null );
159160
160161 ViewState .failure (Object e, StackTrace s)
161162 : this ._([], false , AsyncError (e, s));
0 commit comments