Commit 05f9b20a5fb7fb5f685592dd1614f178638da8d3

Authored by Key
1 parent fcc3a982

fixed: api调用方式,未完善

lib/app/app.dart
... ... @@ -16,9 +16,9 @@ class App extends StatelessWidget {
16 16 Widget build(BuildContext context) {
17 17 return ScreenUtilInit(
18 18 designSize: const Size(667, 375),
19   - builder: (_,__) => MultiBlocProvider(
  19 + builder: (_, __) => MultiBlocProvider(
20 20 providers: [
21   - BlocProvider<TabBloc>(create: (_)=> TabBloc()),
  21 + BlocProvider<TabBloc>(create: (_) => TabBloc()),
22 22 BlocProvider<CacheBloc>(create: (_) => CacheBloc())
23 23 ],
24 24 child: HideKeyboard(
... ... @@ -30,16 +30,13 @@ class App extends StatelessWidget {
30 30 useMaterial3: true,
31 31 ),
32 32 builder: EasyLoading.init(
33   - builder: (context,child) => ResponsiveBreakpoints(
34   - breakpoints: const [
35   - Breakpoint(start: 0, end: 450, name: MOBILE),
36   - Breakpoint(start: 0, end: 450, name: PHONE),
37   - Breakpoint(start: 451, end: 800, name: TABLET),
38   - Breakpoint(start: 801, end: 1920, name: DESKTOP),
39   - Breakpoint(start: 1921, end: double.infinity, name: '4K'),
40   - ],
41   - child: child!)
42   - ),
  33 + builder: (context, child) => ResponsiveBreakpoints(breakpoints: const [
  34 + Breakpoint(start: 0, end: 450, name: MOBILE),
  35 + Breakpoint(start: 0, end: 450, name: PHONE),
  36 + Breakpoint(start: 451, end: 800, name: TABLET),
  37 + Breakpoint(start: 801, end: 1920, name: DESKTOP),
  38 + Breakpoint(start: 1921, end: double.infinity, name: '4K'),
  39 + ], child: child!)),
43 40 initialRoute: AppRouteName.splash,
44 41 navigatorKey: AppRouter.navigatorKey,
45 42 onGenerateRoute: AppRouter.generateRoute,
... ...
lib/common/request/api_response/api_response_entity.g.dart
... ... @@ -16,7 +16,7 @@ ApiResponse&lt;T&gt; $ApiResponseFromJson&lt;T&gt;(Map&lt;String, dynamic&gt; json) {
16 16 String type = T.toString();
17 17 T? data;
18 18 if (kDebugMode) {
19   - print("type:$type");
  19 + print("ApiResponse <T> type:$type");
20 20 }
21 21 if (json['data'] != null) {
22 22 data = jsonConvert.convert<T>(json['data']);
... ...
lib/common/request/config.dart
1 1 ///request config
2 2 class RequestConfig {
3 3 static String baseUrl = 'http://wow-app.dev.kouyuxingqiu.com/';
  4 + static String token = '';
4 5 static const connectTimeout = Duration(seconds: 15);
5 6 static const successCode = 200;
6 7 }
... ...
lib/common/request/dao/user_dao.dart
1   -import '../../../models/user_entity.dart';
2   -import '../api_response/api_response_entity.dart';
  1 +import 'package:wow_english/models/user_entity.dart';
  2 +
3 3 import '../apis.dart';
4   -import '../exception.dart';
5 4 import '../request_client.dart';
6 5  
7 6 class UserDao {
8   - static loginByPassword(
9   - phoneNumber,
10   - password,
11   - Function(ApiResponse<UserEntity>)? onResponse,
12   - bool Function(ApiException)? onError,
13   - ) async {
14   - /*await DioUtil().requestData(
15   - HttpMethod.post,
16   - Api.login,
17   - data: {
18   - 'phoneNum':phoneNumber,
19   - 'type':'pwd',
20   - 'password':password},
21   - successCallBack: (data){
22   - emitter(LoginResultChangeState(true));
23   - },
24   - errorCallBack: (error){
25   - emitter(LoginResultChangeState(false));
26   - });*/
27   - var params = {'phoneNum': phoneNumber, 'type': 'pwd', 'password': password};
28   - await requestClient.post(Apis.login, data: params, onResponse: onResponse, onError: onError);
  7 + static Future<UserEntity?> login(phoneNumber, type, checkKey, checkNumber) {
  8 + var params = {'phoneNum': phoneNumber, 'type': type, checkKey: checkNumber};
  9 + var data = requestClient.post<UserEntity>(
  10 + Apis.login,
  11 + data: params,
  12 + );
  13 + return data;
29 14 }
30   -
31   - static loginBySmsCode(phoneNumber, smsCode) {}
32 15 }
... ...
lib/common/request/exception.dart
1 1 import 'package:dio/dio.dart';
  2 +import 'package:flutter/foundation.dart';
  3 +
2 4 import 'api_response/api_response_entity.dart';
3 5  
4 6 class ApiException implements Exception {
... ... @@ -57,7 +59,11 @@ class ApiException implements Exception {
57 59 return ApiException(errCode, error.response?.statusMessage ?? '未知错误');
58 60 }
59 61 } on Exception catch (e) {
60   - return ApiException(-1, unknownException);
  62 + if (kDebugMode) {
  63 + return ApiException(-1, e.toString());
  64 + } else {
  65 + return ApiException(-1, unknownException);
  66 + }
61 67 }
62 68 default:
63 69 return ApiException(-1, error.message);
... ...
lib/common/request/exception_handler.dart
... ... @@ -2,9 +2,7 @@ import &#39;package:flutter_easyloading/flutter_easyloading.dart&#39;;
2 2  
3 3 import 'exception.dart';
4 4  
5   -
6   -bool handleException(ApiException exception,
7   - {bool Function(ApiException)? onError}) {
  5 +bool handleException(ApiException exception, {bool Function(ApiException)? onError}) {
8 6 if (onError?.call(exception) == true) {
9 7 return true;
10 8 }
... ... @@ -14,6 +12,5 @@ bool handleException(ApiException exception,
14 12 return true;
15 13 }
16 14 EasyLoading.showError(exception.message ?? ApiException.unknownException);
17   -
18 15 return false;
19 16 }
... ...
lib/common/request/request.dart
... ... @@ -2,15 +2,17 @@ import &#39;../../utils/loading.dart&#39;;
2 2 import 'exception.dart';
3 3 import 'exception_handler.dart';
4 4  
5   -Future request(
  5 +Future<T?> request<T>(
6 6 Function() block, {
7   - bool showLoading = true,
  7 + String loadingText = '加载中...',
8 8 bool Function(ApiException)? onError,
9 9 }) async {
10 10 try {
11   - await loading(block, isShowLoading: showLoading);
  11 + return await loading(block, loadingText: loadingText);
12 12 } catch (e) {
13   - handleException(ApiException.from(e), onError: onError);
  13 + if (!handleException(ApiException.from(e), onError: onError)) {
  14 + rethrow;
  15 + }
14 16 }
15   - return;
  17 + return null;
16 18 }
... ...
lib/common/request/request_client.dart
... ... @@ -45,7 +45,6 @@ class RequestClient {
45 45 throw exception;
46 46 }
47 47 }
48   -
49 48 return null;
50 49 }
51 50  
... ... @@ -132,7 +131,6 @@ class RequestClient {
132 131 Function(ApiResponse<T>)? onResponse,
133 132 ) {
134 133 int statusCode = response.statusCode ?? -1;
135   - print('statusCode=$statusCode');
136 134 // 200..299 成功响应
137 135 if (statusCode >= 200 && statusCode <= 299) {
138 136 if (T.toString() == (RawData).toString()) {
... ...
lib/common/request/token_interceptor.dart
1 1 import 'package:dio/dio.dart';
  2 +import 'package:wow_english/common/request/config.dart';
2 3  
3 4 class TokenInterceptor extends Interceptor {
4 5 @override
5 6 void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
6   - /// todo 判断token不为空插入
7   - options.headers["Auth-token"] = '';
  7 + // 判断token不为空插入, todo token的取法应该跟user在一起,这里取不到user
  8 + if (RequestConfig.token.isNotEmpty) {
  9 + options.headers["Auth-token"] = RequestConfig.token;
  10 + }
8 11 options.headers["version"] = '1.0.0';
9 12 super.onRequest(options, handler);
10 13 }
... ...
lib/pages/login/loginpage/bloc/login_bloc.dart
1   -import 'dart:js';
2   -
3 1 import 'package:flutter/cupertino.dart';
4 2 import 'package:flutter_bloc/flutter_bloc.dart';
5 3 import 'package:flutter_easyloading/flutter_easyloading.dart';
6   -
7   -import '../../../../common/request/api_response/api_response_entity.dart';
8   -import '../../../../common/request/apis.dart';
9   -import '../../../../common/request/request.dart';
10   -import '../../../../common/request/request_client.dart';
11   -import '../../../../models/user_entity.dart';
  4 +import 'package:wow_english/common/request/config.dart';
  5 +import 'package:wow_english/common/request/dao/user_dao.dart';
  6 +import 'package:wow_english/models/user_entity.dart';
  7 +import 'package:wow_english/utils/loading.dart';
12 8  
13 9 part 'login_event.dart';
14 10 part 'login_state.dart';
... ... @@ -73,29 +69,22 @@ class LoginBloc extends Bloc&lt;LoginEvent, LoginState&gt; {
73 69 var checkKey = _isSmsLoginType ? 'smsCode' : 'password';
74 70 var type = _isSmsLoginType ? 'sms_code' : 'pwd';
75 71  
76   - request(() async {
77   - var params = {'phoneNum': phoneNumber, 'type': type, checkKey: checkNumber};
78   - await requestClient.post(
79   - Apis.login,
80   - data: params,
81   - onResponse: (ApiResponse<UserEntity> response) {
82   - print('response=$response');
83   - // todo 持久化用户对象
84   - // todo 写入全局对象
85   - //emitter.call(LoginResultChangeState());
86   - },
87   - onError: (e) {
88   - EasyLoading.showToast('登陆失败:${e.message}');
89   - return true;
90   - },
91   - );
92   - });
  72 + try {
  73 + await loading(() async {
  74 + var user = await UserDao.login(phoneNumber, type, checkKey, checkNumber);
  75 + print('login已执行');
  76 + print('user=$user');
  77 + RequestConfig.token = user!.token;
  78 + emitter.call(LoginResultChangeState(user));
  79 + });
  80 + } catch (e) {
  81 + print(e);
  82 + EasyLoading.showToast('登陆失败');
  83 + }
93 84 }
94 85  
95 86 ///请求验证码
96   - void _requestSmsCodeApi(RequestSmsCodeEvent event, Emitter<LoginState> emitter) async {
97   -
98   - }
  87 + void _requestSmsCodeApi(RequestSmsCodeEvent event, Emitter<LoginState> emitter) async {}
99 88  
100 89 ///切换登陆方式
101 90 void _changeLoginType(ChangeLoginTypeEvent event, Emitter<LoginState> emitter) async {
... ...
lib/pages/login/loginpage/bloc/login_state.dart
... ... @@ -16,8 +16,13 @@ class SmsSendTypeChangeState extends LoginState {}
16 16  
17 17 ///是否同意协议
18 18 class AgreementTypeChangeState extends LoginState {}
  19 +
19 20 ///获取验证码
20   -class SmsCodeRequestState extends LoginState {}
  21 +class SmsCodeRequestState extends LoginState {}
21 22  
22 23 ///登陆请求结果
23   -class LoginResultChangeState extends LoginState {}
  24 +class LoginResultChangeState extends LoginState {
  25 + final UserEntity userEntity;
  26 +
  27 + LoginResultChangeState(this.userEntity);
  28 +}
... ...
lib/pages/login/loginpage/login_page.dart
... ... @@ -25,169 +25,139 @@ class LoginPage extends StatelessWidget {
25 25 class _LoginPageView extends StatelessWidget {
26 26 @override
27 27 Widget build(BuildContext context) {
28   - return BlocListener<LoginBloc,LoginState>(
29   - listener: (context, state){
30   - if (state is LoginResultChangeState) {
31   - Navigator.of(context).pushNamed(AppRouteName.home);
32   - }
33   - context.read<CacheBloc>().add(UserInfoChangeEvent(null));
34   - },
  28 + return BlocListener<LoginBloc, LoginState>(
  29 + listener: (context, state) {
  30 + if (state is LoginResultChangeState) {
  31 + context.read<CacheBloc>().add(UserInfoChangeEvent(state.userEntity));
  32 + Navigator.of(context).pushNamed(AppRouteName.home);
  33 + }
  34 + },
35 35 child: _buildLoginViewWidget(),
36 36 );
37 37 }
38 38  
39   - Widget _buildLoginViewWidget() => BlocBuilder<LoginBloc,LoginState> (
40   - builder: (context, state) {
41   - final bloc = BlocProvider.of<LoginBloc>(context);
42   - return Scaffold(
43   - body: SafeArea(
44   - child: ListView(
45   - children: [
46   - Container(
47   - padding: EdgeInsets.only(top: 25.h),
48   - child: Stack(
49   - children: [
50   - Positioned(
51   - right: 29.w,
52   - child: GestureDetector(
53   - onTap: () => bloc.add(ChangeLoginTypeEvent()),
54   - child: Container(
55   - decoration: BoxDecoration(
56   - image: DecorationImage(
57   - image: AssetImage(
58   - 'login_logo'.assetPng
59   - ),
60   - fit: BoxFit.fill
61   - ),
62   - ),
63   - padding: EdgeInsets.symmetric(horizontal: 18.w,vertical: 5.h),
64   - child: Text(
65   - bloc.isSmsLoginType?'密码登陆':'验证码密码',
66   - style: TextStyle(
67   - fontSize: 16.sp
  39 + Widget _buildLoginViewWidget() => BlocBuilder<LoginBloc, LoginState>(
  40 + builder: (context, state) {
  41 + final bloc = BlocProvider.of<LoginBloc>(context);
  42 + return Scaffold(
  43 + body: SafeArea(
  44 + child: ListView(
  45 + children: [
  46 + Container(
  47 + padding: EdgeInsets.only(top: 25.h),
  48 + child: Stack(
  49 + children: [
  50 + Positioned(
  51 + right: 29.w,
  52 + child: GestureDetector(
  53 + onTap: () => bloc.add(ChangeLoginTypeEvent()),
  54 + child: Container(
  55 + decoration: BoxDecoration(
  56 + image: DecorationImage(image: AssetImage('login_logo'.assetPng), fit: BoxFit.fill),
  57 + ),
  58 + padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h),
  59 + child: Text(
  60 + bloc.isSmsLoginType ? '密码登陆' : '验证码密码',
  61 + style: TextStyle(fontSize: 16.sp),
  62 + ),
68 63 ),
69   - ),
70   - ),
71   - )
72   - ),
73   - Center(
74   - child: Column(
75   - children: [
76   - Image.asset(
77   - 'wow_logo'.assetPng,
78   - height: 81.h,
79   - width: 131.w,
80   - ),
81   - Offstage(
82   - offstage: !bloc.isSmsLoginType,
83   - child: _buildSmsViewWidget(),
84   - ),
85   - Offstage(
86   - offstage: bloc.isSmsLoginType,
87   - child: _buildPwdViewWidget(),
88   - ),
89   - Row(
90   - mainAxisAlignment: MainAxisAlignment.center,
  64 + )),
  65 + Center(
  66 + child: Column(
91 67 children: [
92   - GestureDetector(
93   - onTap: () => bloc.add(AgreementChangeEvent()),
94   - child: Icon(
95   - bloc.agreement ? Icons.check_circle_outlined:Icons.circle_outlined,
96   - color:bloc.agreement ? Colors.green:Colors.black),
  68 + Image.asset(
  69 + 'wow_logo'.assetPng,
  70 + height: 81.h,
  71 + width: 131.w,
  72 + ),
  73 + Offstage(
  74 + offstage: !bloc.isSmsLoginType,
  75 + child: _buildSmsViewWidget(),
97 76 ),
98   - 6.horizontalSpace,
99   - RichText(
100   - text: TextSpan(
101   - children:[
  77 + Offstage(
  78 + offstage: bloc.isSmsLoginType,
  79 + child: _buildPwdViewWidget(),
  80 + ),
  81 + Row(
  82 + mainAxisAlignment: MainAxisAlignment.center,
  83 + children: [
  84 + GestureDetector(
  85 + onTap: () => bloc.add(AgreementChangeEvent()),
  86 + child: Icon(bloc.agreement ? Icons.check_circle_outlined : Icons.circle_outlined,
  87 + color: bloc.agreement ? Colors.green : Colors.black),
  88 + ),
  89 + 6.horizontalSpace,
  90 + RichText(
  91 + text: TextSpan(children: [
102 92 TextSpan(
103 93 text: '我已阅读并同意',
104 94 style: TextStyle(
105 95 fontSize: 12.sp,
106 96 color: const Color(0xFF333333),
107   - )
108   - ),
  97 + )),
109 98 TextSpan(
110 99 text: '《用户隐私协议》',
111 100 style: TextStyle(
112 101 fontSize: 12.sp,
113 102 color: const Color(0xFF333333),
114 103 ),
115   - recognizer: TapGestureRecognizer()..onTap = (){
116   - Navigator.of(context).pushNamed(
117   - AppRouteName.webView,
118   - arguments: {
119   - 'urlStr':'https://www.zhihu.com',
120   - 'webViewTitle':'用户隐私协议'
121   - });
122   - }),
123   - TextSpan(
124   - text: ',',
125   - style: TextStyle(
126   - fontSize: 12.sp,
127   - color: const Color(0xFF333333)
128   - )
129   - ),
  104 + recognizer: TapGestureRecognizer()
  105 + ..onTap = () {
  106 + Navigator.of(context).pushNamed(AppRouteName.webView, arguments: {
  107 + 'urlStr': 'https://www.zhihu.com',
  108 + 'webViewTitle': '用户隐私协议'
  109 + });
  110 + }),
  111 + TextSpan(
  112 + text: ',', style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333))),
130 113 TextSpan(
131 114 text: '《儿童隐私政策》',
132   - style: TextStyle(
133   - fontSize: 12.sp,
134   - color: const Color(0xFF333333)
135   - ),
136   - recognizer: TapGestureRecognizer()..onTap = (){
137   - Navigator.of(context).pushNamed(
138   - AppRouteName.webView,
139   - arguments: {
140   - 'urlStr':'https://www.zhihu.com',
141   - 'webViewTitle':'儿童隐私协议'
142   - });
143   - })
144   - ]
  115 + style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333)),
  116 + recognizer: TapGestureRecognizer()
  117 + ..onTap = () {
  118 + Navigator.of(context).pushNamed(AppRouteName.webView, arguments: {
  119 + 'urlStr': 'https://www.zhihu.com',
  120 + 'webViewTitle': '儿童隐私协议'
  121 + });
  122 + })
  123 + ]),
  124 + )
  125 + ],
  126 + ),
  127 + GestureDetector(
  128 + onTap: () {
  129 + if (bloc.canLogin) {
  130 + bloc.add(RequestLoginEvent());
  131 + }
  132 + },
  133 + child: Container(
  134 + decoration: BoxDecoration(
  135 + image: DecorationImage(
  136 + image: AssetImage(
  137 + bloc.canLogin ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng),
  138 + fit: BoxFit.fill),
  139 + ),
  140 + padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h),
  141 + child: Text(
  142 + '登录',
  143 + style: TextStyle(fontSize: 16.sp),
  144 + ),
145 145 ),
146 146 )
147 147 ],
148 148 ),
149   - GestureDetector(
150   - onTap: () {
151   - if (bloc.canLogin) {
152   - bloc.add(RequestLoginEvent());
153   - }
154   - },
155   - child: Container(
156   - decoration: BoxDecoration(
157   - image: DecorationImage(
158   - image: AssetImage(
159   - bloc.canLogin?'login_enter'.assetPng:'login_enter_dis'.assetPng
160   - ),
161   - fit: BoxFit.fill
162   - ),
163   - ),
164   - padding: EdgeInsets.symmetric(
165   - horizontal: 28.w,
166   - vertical: 14.h
167   - ),
168   - child: Text(
169   - '登录',
170   - style: TextStyle(
171   - fontSize: 16.sp
172   - ),
173   - ),
174   - ),
175   - )
176   - ],
177   - ),
178   - )
179   - ],
180   - ),
181   - )
182   - ],
183   - ),
184   - ),
  149 + )
  150 + ],
  151 + ),
  152 + )
  153 + ],
  154 + ),
  155 + ),
  156 + );
  157 + },
185 158 );
186   - },
187   - );
188 159  
189   - Widget _buildSmsViewWidget()=> BlocBuilder<LoginBloc,LoginState>(
190   - builder: (context,state) {
  160 + Widget _buildSmsViewWidget() => BlocBuilder<LoginBloc, LoginState>(builder: (context, state) {
191 161 final bloc = BlocProvider.of<LoginBloc>(context);
192 162 return Padding(
193 163 padding: EdgeInsets.symmetric(horizontal: 135.w),
... ... @@ -205,27 +175,25 @@ class _LoginPageView extends StatelessWidget {
205 175 controller: bloc.phoneNumController,
206 176 ),
207 177 6.5.verticalSpace,
208   - Text('未注册用户登录默认注册',
209   - style: TextStyle(
210   - fontSize: 12.sp,
211   - color: const Color(0xFF999999)
212   - ),),
  178 + Text(
  179 + '未注册用户登录默认注册',
  180 + style: TextStyle(fontSize: 12.sp, color: const Color(0xFF999999)),
  181 + ),
213 182 4.5.verticalSpace,
214 183 Row(
215 184 mainAxisAlignment: MainAxisAlignment.spaceBetween,
216 185 children: [
217 186 Expanded(
218 187 child: TextFieldCustomerWidget(
219   - height: 50.h,
220   - hitText: '请输入验证码',
221   - textInputType: TextInputType.number,
222   - bgImageName: 'Input_layer_down',
223   - onChangeValue: (String value) {
224   - bloc.add(CheckFieldChangeEvent());
225   - },
226   - controller: bloc.checkNumController,
227   - )
228   - ),
  188 + height: 50.h,
  189 + hitText: '请输入验证码',
  190 + textInputType: TextInputType.number,
  191 + bgImageName: 'Input_layer_down',
  192 + onChangeValue: (String value) {
  193 + bloc.add(CheckFieldChangeEvent());
  194 + },
  195 + controller: bloc.checkNumController,
  196 + )),
229 197 TimerWidget(canSendSms: bloc.canSendSms)
230 198 ],
231 199 )
... ... @@ -234,8 +202,7 @@ class _LoginPageView extends StatelessWidget {
234 202 );
235 203 });
236 204  
237   - Widget _buildPwdViewWidget()=> BlocBuilder<LoginBloc,LoginState>(
238   - builder: (context,state){
  205 + Widget _buildPwdViewWidget() => BlocBuilder<LoginBloc, LoginState>(builder: (context, state) {
239 206 final bloc = BlocProvider.of<LoginBloc>(context);
240 207 return Padding(
241 208 padding: EdgeInsets.symmetric(horizontal: 90.w),
... ... @@ -253,16 +220,15 @@ class _LoginPageView extends StatelessWidget {
253 220 10.5.horizontalSpace,
254 221 Expanded(
255 222 child: TextFieldCustomerWidget(
256   - height: 50.h,
257   - hitText: '请输入手机号',
258   - textInputType: TextInputType.phone,
259   - bgImageName: 'Input_layer_up',
260   - onChangeValue: (String value) {
261   - bloc.add(PhoneNumChangeEvent());
262   - },
263   - controller: bloc.phoneNumController,
264   - )
265   - ),
  223 + height: 50.h,
  224 + hitText: '请输入手机号',
  225 + textInputType: TextInputType.phone,
  226 + bgImageName: 'Input_layer_up',
  227 + onChangeValue: (String value) {
  228 + bloc.add(PhoneNumChangeEvent());
  229 + },
  230 + controller: bloc.phoneNumController,
  231 + )),
266 232 5.horizontalSpace,
267 233 SizedBox(
268 234 width: 100.w,
... ... @@ -282,14 +248,13 @@ class _LoginPageView extends StatelessWidget {
282 248 10.5.horizontalSpace,
283 249 Expanded(
284 250 child: TextFieldCustomerWidget(
285   - hitText: '请输入密码',
286   - bgImageName: 'Input_layer_down',
287   - onChangeValue: (String value) {
288   - bloc.add(CheckFieldChangeEvent());
289   - },
290   - controller: bloc.checkNumController,
291   - )
292   - ),
  251 + hitText: '请输入密码',
  252 + bgImageName: 'Input_layer_down',
  253 + onChangeValue: (String value) {
  254 + bloc.add(CheckFieldChangeEvent());
  255 + },
  256 + controller: bloc.checkNumController,
  257 + )),
293 258 5.horizontalSpace,
294 259 GestureDetector(
295 260 onTap: () {
... ... @@ -301,9 +266,7 @@ class _LoginPageView extends StatelessWidget {
301 266 alignment: Alignment.centerLeft,
302 267 child: Text(
303 268 '忘记密码 ?',
304   - style: TextStyle(
305   - fontSize: 12.sp
306   - ),
  269 + style: TextStyle(fontSize: 12.sp),
307 270 ),
308 271 ),
309 272 )
... ...
lib/utils/loading.dart
1 1 import 'package:flutter_easyloading/flutter_easyloading.dart';
2 2  
3   -Future loading(Function block, {bool isShowLoading = true}) async {
4   - if (isShowLoading) {
5   - showLoading();
  3 +Future<T?> loading<T>(Function block, {String loadingText = '加载中...'}) async {
  4 + if (loadingText.isNotEmpty) {
  5 + showLoading(loadingText);
6 6 }
7 7 try {
8   - await block();
  8 + return await block();
9 9 } catch (e) {
10 10 rethrow;
11 11 } finally {
12 12 dismissLoading();
13 13 }
14   - return;
15 14 }
16 15  
17   -void showLoading() {
18   - EasyLoading.show(status: "加载中...");
  16 +void showLoading(String text) {
  17 + EasyLoading.show(status: text);
19 18 }
20 19  
21 20 void dismissLoading() {
... ...