Blame view

lib/common/blocs/cachebloc/cache_bloc.dart 772 Bytes
fcc3a982   liangchengyou   feat:全局缓存bloc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  import 'package:flutter/cupertino.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
  import 'package:wow_english/models/user_entity.dart';
  
  part 'cache_event.dart';
  part 'cache_state.dart';
  
  class CacheBloc extends Bloc<CacheEvent, CacheState> {
    UserEntity? _userEntity;
  
    UserEntity? get userEntity => _userEntity;
  
    CacheBloc() : super(CacheInitial()) {
      on<UserInfoChangeEvent>(_userInfoChange);
2b55d503   liangchengyou   feat:添加插件
15
      on<UserInfoClearEvent>(_userInfoClear);
fcc3a982   liangchengyou   feat:全局缓存bloc
16
17
18
19
20
21
22
23
24
25
26
27
    }
  
    void _userInfoChange(UserInfoChangeEvent event,Emitter<CacheState> emitter) async {
      _userEntity = event.userEntity;
      emitter(UserInfoChangeState());
    }
  
    void _userInfoClear(UserInfoClearEvent event,Emitter<CacheState> emitter) async {
      _userEntity = null;
      emitter(UserInfoClearState());
    }
  }