Commit 2b55d503c2fa28021e799e0793fdf012ade41d61
1 parent
089ccd5c
feat:添加插件
Showing
4 changed files
with
10 additions
and
4 deletions
lib/common/blocs/cachebloc/cache_bloc.dart
| ... | ... | @@ -12,6 +12,7 @@ class CacheBloc extends Bloc<CacheEvent, CacheState> { |
| 12 | 12 | |
| 13 | 13 | CacheBloc() : super(CacheInitial()) { |
| 14 | 14 | on<UserInfoChangeEvent>(_userInfoChange); |
| 15 | + on<UserInfoClearEvent>(_userInfoClear); | |
| 15 | 16 | } |
| 16 | 17 | |
| 17 | 18 | void _userInfoChange(UserInfoChangeEvent event,Emitter<CacheState> emitter) async { | ... | ... |
lib/pages/home/widgets/home_tab_header_widget.dart
| 1 | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_bloc/flutter_bloc.dart'; | |
| 2 | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 4 | +import 'package:wow_english/common/blocs/cachebloc/cache_bloc.dart'; | |
| 3 | 5 | import 'package:wow_english/common/extension/string_extension.dart'; |
| 4 | 6 | |
| 5 | 7 | enum HeaderActionType { |
| ... | ... | @@ -45,10 +47,10 @@ class HomeTabHeaderWidget extends StatelessWidget { |
| 45 | 47 | ), |
| 46 | 48 | borderRadius: BorderRadius.circular(21), |
| 47 | 49 | ), |
| 48 | - child: const CircleAvatar( | |
| 50 | + child: CircleAvatar( | |
| 49 | 51 | radius: 21, |
| 50 | 52 | backgroundImage: NetworkImage( |
| 51 | - 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Faa1c2213-820a-4223-8757-5f8cee318a28%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1688713226&t=192b18a613683bcdc5bd76f65c9ff032' | |
| 53 | + context.read<CacheBloc>().userEntity?.avatarUrl??'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Faa1c2213-820a-4223-8757-5f8cee318a28%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1688713226&t=192b18a613683bcdc5bd76f65c9ff032', | |
| 52 | 54 | ), |
| 53 | 55 | ), |
| 54 | 56 | ), |
| ... | ... | @@ -72,7 +74,7 @@ class HomeTabHeaderWidget extends StatelessWidget { |
| 72 | 74 | ), |
| 73 | 75 | ), |
| 74 | 76 | child: Text( |
| 75 | - 'franky', | |
| 77 | + context.read<CacheBloc>().userEntity?.name??'', | |
| 76 | 78 | style: TextStyle( |
| 77 | 79 | color: const Color(0xFF333333), |
| 78 | 80 | fontSize: 16.sp | ... | ... |
lib/pages/login/loginpage/bloc/login_bloc.dart
| ... | ... | @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; |
| 2 | 2 | import 'package:flutter_bloc/flutter_bloc.dart'; |
| 3 | 3 | import 'package:flutter_easyloading/flutter_easyloading.dart'; |
| 4 | 4 | import 'package:wow_english/common/request/dao/user_dao.dart'; |
| 5 | +import 'package:wow_english/common/request/exception.dart'; | |
| 5 | 6 | import 'package:wow_english/models/user_entity.dart'; |
| 6 | 7 | import 'package:wow_english/utils/loading.dart'; |
| 7 | 8 | |
| ... | ... | @@ -75,7 +76,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
| 75 | 76 | emitter.call(LoginResultChangeState(user!)); |
| 76 | 77 | }); |
| 77 | 78 | } catch (e) { |
| 78 | - print(e); | |
| 79 | + print((e as ApiException).message); | |
| 79 | 80 | EasyLoading.showToast('登陆失败'); |
| 80 | 81 | } |
| 81 | 82 | } | ... | ... |
pubspec.yaml
| ... | ... | @@ -91,6 +91,8 @@ dependencies: |
| 91 | 91 | video_player: ^2.6.1 |
| 92 | 92 | # UI适配 https://pub.dev/packages/responsive_framework |
| 93 | 93 | responsive_framework: ^1.0.0 |
| 94 | + # 音频播放 https://pub.dev/packages/audioplayers | |
| 95 | + audioplayers: ^4.1.0 | |
| 94 | 96 | |
| 95 | 97 | dev_dependencies: |
| 96 | 98 | build_runner: ^2.4.4 | ... | ... |