Skip to content

Commit f501ce3

Browse files
committed
fix #836
1 parent 6fa75b6 commit f501ce3

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

lib/app.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
5353
]);
5454

5555

56+
57+
5658
@override
5759
void initState() {
5860
super.initState();
@@ -76,7 +78,7 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
7678
///使用 StoreBuilder 获取 store 中的 theme 、locale
7779
store.state.platformLocale = WidgetsBinding.instance.window.locale;
7880
Widget app = new MaterialApp(
79-
81+
navigatorKey: navKey,
8082
///多语言实现代理
8183
localizationsDelegates: [
8284
GlobalMaterialLocalizations.delegate,
@@ -146,6 +148,8 @@ mixin HttpErrorListener on State<FlutterReduxApp> {
146148
///所以如果直接用 context 是会获取不到 MaterialApp 的 Localizations 哦。
147149
late BuildContext _context;
148150

151+
GlobalKey<NavigatorState> navKey = GlobalKey();
152+
149153
@override
150154
void initState() {
151155
super.initState();
@@ -167,32 +171,33 @@ mixin HttpErrorListener on State<FlutterReduxApp> {
167171

168172
///网络错误提醒
169173
errorHandleFunction(int? code, message) {
174+
var context = navKey.currentContext!;
170175
switch (code) {
171176
case Code.NETWORK_ERROR:
172-
showToast(GSYLocalizations.i18n(_context)!.network_error);
177+
showToast(GSYLocalizations.i18n(context)!.network_error);
173178
break;
174179
case 401:
175-
showToast(GSYLocalizations.i18n(_context)!.network_error_401);
180+
showToast(GSYLocalizations.i18n(context)!.network_error_401);
176181
break;
177182
case 403:
178-
showToast(GSYLocalizations.i18n(_context)!.network_error_403);
183+
showToast(GSYLocalizations.i18n(context)!.network_error_403);
179184
break;
180185
case 404:
181-
showToast(GSYLocalizations.i18n(_context)!.network_error_404);
186+
showToast(GSYLocalizations.i18n(context)!.network_error_404);
182187
break;
183188
case 422:
184-
showToast(GSYLocalizations.i18n(_context)!.network_error_422);
189+
showToast(GSYLocalizations.i18n(context)!.network_error_422);
185190
break;
186191
case Code.NETWORK_TIMEOUT:
187192
//超时
188-
showToast(GSYLocalizations.i18n(_context)!.network_error_timeout);
193+
showToast(GSYLocalizations.i18n(context)!.network_error_timeout);
189194
break;
190195
case Code.GITHUB_API_REFUSED:
191196
//Github API 异常
192-
showToast(GSYLocalizations.i18n(_context)!.github_refused);
197+
showToast(GSYLocalizations.i18n(context)!.github_refused);
193198
break;
194199
default:
195-
showToast(GSYLocalizations.i18n(_context)!.network_error_unknown +
200+
showToast(GSYLocalizations.i18n(context)!.network_error_unknown +
196201
" " +
197202
message);
198203
break;

lib/widget/gsy_input_widget.dart

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,22 @@ class GSYInputWidget extends StatefulWidget {
2929

3030
/// State for [GSYInputWidget] widgets.
3131
class _GSYInputWidgetState extends State<GSYInputWidget> {
32-
3332
@override
3433
Widget build(BuildContext context) {
3534
return new TextField(
36-
controller: widget.controller,
37-
onChanged: widget.onChanged,
38-
obscureText: widget.obscureText,
39-
decoration: new InputDecoration(
40-
hintText: widget.hintText,
41-
icon: widget.iconData == null ? null : new Icon(widget.iconData),
42-
),
43-
);
35+
controller: widget.controller,
36+
onChanged: widget.onChanged,
37+
obscureText: widget.obscureText,
38+
decoration: new InputDecoration(
39+
hintText: widget.hintText,
40+
icon: widget.iconData == null ? null : new Icon(widget.iconData),
41+
),
42+
magnifierConfiguration: TextMagnifierConfiguration(magnifierBuilder: (
43+
BuildContext context,
44+
MagnifierController controller,
45+
ValueNotifier<MagnifierInfo> magnifierInfo,
46+
) {
47+
return null;
48+
}));
4449
}
4550
}

0 commit comments

Comments
 (0)