@@ -7,34 +7,34 @@ import 'package:flutter_bloc/flutter_bloc.dart';
77import 'package:l10n/l10n.dart' ;
88import 'package:storage/storage.dart' ;
99
10-
1110/// create by 张风捷特烈 on 2020-03-22
1211/// contact me by email [email protected] 1312/// 说明: 全局信息的bloc
1413
1514class AppConfigBloc extends Cubit <AppConfigState > {
16-
1715 final Connectivity _connectivity = Connectivity ();
1816
19- late StreamSubscription <ConnectivityResult > _subscription;
17+ late StreamSubscription <List < ConnectivityResult > > _subscription;
2018
21- AppConfigBloc () : super (const AppConfigState ()){
19+ AppConfigBloc () : super (const AppConfigState ()) {
2220 _subscription = _connectivity.onConnectivityChanged.listen (_onNetConnectChange);
2321 }
2422
25- void _onNetConnectChange (ConnectivityResult event) {
26- emit (state.copyWith (netConnect: event,));
23+ void _onNetConnectChange (List <ConnectivityResult > event) {
24+ if (event.isNotEmpty) {
25+ emit (state.copyWith (
26+ netConnect: event.first,
27+ ));
28+ }
2729 }
2830
29-
3031 @override
31- Future <void > close () async {
32+ Future <void > close () async {
3233 _subscription.cancel ();
3334 super .close ();
3435 }
3536
36-
37- void init (AppConfigState state){
37+ void init (AppConfigState state) {
3838 emit (state);
3939 }
4040
@@ -89,13 +89,13 @@ class AppConfigBloc extends Cubit<AppConfigState> {
8989 emit (newState);
9090 }
9191
92- void changeThemeMode (ThemeMode style) async {
92+ void changeThemeMode (ThemeMode style) async {
9393 AppConfigState newState = state.copyWith (themeMode: style);
9494 cao.write (newState.toAppConfigPo ());
9595 emit (newState);
9696 }
9797
98- void switchShowTool (bool show) async {
98+ void switchShowTool (bool show) async {
9999 AppConfigState newState = state.copyWith (showOverlayTool: show);
100100 cao.write (newState.toAppConfigPo ());
101101 emit (newState);
0 commit comments