Skip to content

Commit 40faf94

Browse files
committed
update support 3.10
1 parent d228ff7 commit 40faf94

File tree

11 files changed

+54
-215
lines changed

11 files changed

+54
-215
lines changed

android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
1717
apply from: "exported.gradle"
1818

1919
android {
20-
compileSdkVersion 32
20+
compileSdkVersion 33
2121

2222
sourceSets {
2323
main.java.srcDirs += 'src/main/kotlin'

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ subprojects {
2626
project.evaluationDependsOn(':app')
2727
}
2828

29-
task clean(type: Delete) {
29+
tasks.register("clean", Delete) {
3030
delete rootProject.buildDir
3131
}

lib/app.dart

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import 'dart:async';
22

33
import 'package:flutter/material.dart';
44
import 'package:flutter_localizations/flutter_localizations.dart';
5+
import 'package:flutter_redux/flutter_redux.dart';
56
import 'package:fluttertoast/fluttertoast.dart';
67
import 'package:gsy_github_app_flutter/common/event/http_error_event.dart';
78
import 'package:gsy_github_app_flutter/common/event/index.dart';
89
import 'package:gsy_github_app_flutter/common/localization/default_localizations.dart';
910
import 'package:gsy_github_app_flutter/common/localization/gsy_localizations_delegate.dart';
10-
import 'package:gsy_github_app_flutter/page/debug/debug_label.dart';
11-
import 'package:gsy_github_app_flutter/page/photoview_page.dart';
12-
import 'package:gsy_github_app_flutter/redux/gsy_state.dart';
13-
import 'package:gsy_github_app_flutter/model/User.dart';
11+
import 'package:gsy_github_app_flutter/common/net/code.dart';
1412
import 'package:gsy_github_app_flutter/common/style/gsy_style.dart';
1513
import 'package:gsy_github_app_flutter/common/utils/common_utils.dart';
14+
import 'package:gsy_github_app_flutter/model/User.dart';
15+
import 'package:gsy_github_app_flutter/page/debug/debug_label.dart';
1616
import 'package:gsy_github_app_flutter/page/home/home_page.dart';
1717
import 'package:gsy_github_app_flutter/page/login/login_page.dart';
18+
import 'package:gsy_github_app_flutter/page/photoview_page.dart';
1819
import 'package:gsy_github_app_flutter/page/welcome_page.dart';
19-
import 'package:flutter_redux/flutter_redux.dart';
20+
import 'package:gsy_github_app_flutter/redux/gsy_state.dart';
2021
import 'package:redux/redux.dart';
21-
import 'package:gsy_github_app_flutter/common/net/code.dart';
2222

2323
import 'common/utils/navigator_utils.dart';
2424

@@ -28,7 +28,7 @@ class FlutterReduxApp extends StatefulWidget {
2828
}
2929

3030
class _FlutterReduxAppState extends State<FlutterReduxApp>
31-
with HttpErrorListener, NavigatorObserver {
31+
with HttpErrorListener {
3232
/// 创建Store,引用 GSYState 中的 appReducer 实现 Reducer 方法
3333
/// initialState 初始化 State
3434
final store = new Store<GSYState>(
@@ -53,6 +53,7 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
5353
]);
5454

5555

56+
NavigatorObserver navigatorObserver = NavigatorObserver();
5657

5758

5859
@override
@@ -63,8 +64,8 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
6364
/// MaterialApp 和 StoreProvider 的 context
6465
/// 还可以获取到 navigator;
6566
/// 比如在这里增加一个监听,如果 token 失效就退回登陆页。
66-
navigator!.context;
67-
navigator;
67+
navigatorObserver.navigator!.context;
68+
navigatorObserver.navigator;
6869
});
6970
}
7071

@@ -76,7 +77,7 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
7677
store: store,
7778
child: new StoreBuilder<GSYState>(builder: (context, store) {
7879
///使用 StoreBuilder 获取 store 中的 theme 、locale
79-
store.state.platformLocale = WidgetsBinding.instance.window.locale;
80+
store.state.platformLocale = WidgetsBinding.instance.platformDispatcher.locale;
8081
Widget app = new MaterialApp(
8182
navigatorKey: navKey,
8283
///多语言实现代理
@@ -91,7 +92,7 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
9192
],
9293
locale: store.state.locale,
9394
theme: store.state.themeData,
94-
navigatorObservers: [this],
95+
navigatorObservers: [navigatorObserver],
9596

9697
///命名式路由
9798
/// "/" 和 MaterialApp 的 home 参数一个效果
@@ -104,16 +105,13 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
104105
///⚠️ 这个是我故意的,如果不需要,可以去掉 pageContainer 或者不要用这里的 context
105106
routes: {
106107
WelcomePage.sName: (context) {
107-
_context = context;
108108
DebugLabel.showDebugLabel(context);
109109
return WelcomePage();
110110
},
111111
HomePage.sName: (context) {
112-
_context = context;
113112
return NavigatorUtils.pageContainer(new HomePage(), context);
114113
},
115114
LoginPage.sName: (context) {
116-
_context = context;
117115
return NavigatorUtils.pageContainer(new LoginPage(), context);
118116
},
119117

@@ -138,16 +136,12 @@ class _FlutterReduxAppState extends State<FlutterReduxApp>
138136
}),
139137
);
140138
}
139+
141140
}
142141

143142
mixin HttpErrorListener on State<FlutterReduxApp> {
144143
StreamSubscription? stream;
145144

146-
///这里为什么用 _context 你理解吗?
147-
///因为此时 State 的 context 是 FlutterReduxApp 而不是 MaterialApp
148-
///所以如果直接用 context 是会获取不到 MaterialApp 的 Localizations 哦。
149-
late BuildContext _context;
150-
151145
GlobalKey<NavigatorState> navKey = GlobalKey();
152146

153147
@override
@@ -211,3 +205,4 @@ mixin HttpErrorListener on State<FlutterReduxApp> {
211205
toastLength: Toast.LENGTH_LONG);
212206
}
213207
}
208+

lib/common/utils/common_utils.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class CommonUtils {
269269
store.dispatch(RefreshLocaleAction(locale));
270270
}
271271

272-
273272
/**
274273
* 切换灰色
275274
*/
@@ -306,9 +305,11 @@ class CommonUtils {
306305
}
307306

308307
static copy(String? data, BuildContext context) {
309-
Clipboard.setData(new ClipboardData(text: data));
310-
Fluttertoast.showToast(
311-
msg: GSYLocalizations.i18n(context)!.option_share_copy_success);
308+
if (data != null) {
309+
Clipboard.setData(new ClipboardData(text: data));
310+
Fluttertoast.showToast(
311+
msg: GSYLocalizations.i18n(context)!.option_share_copy_success);
312+
}
312313
}
313314

314315
static launchUrl(context, String? url) {

lib/common/utils/navigator_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ class NavigatorUtils {
326326
return MediaQuery(
327327

328328
///不受系统字体缩放影响
329-
data: MediaQueryData.fromWindow(WidgetsBinding.instance.window)
329+
data: MediaQueryData.fromView(WidgetsBinding.instance.platformDispatcher.views.first)
330330
.copyWith(textScaleFactor: 1),
331331
child: NeverOverScrollIndicator(
332332
needOverload: false,

lib/page/error_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class ErrorPageState extends State<ErrorPage> {
3737
@override
3838
Widget build(BuildContext context) {
3939
double width =
40-
MediaQueryData.fromWindow(WidgetsBinding.instance.window).size.width;
40+
MediaQueryData.fromView(View.of(context)).size.width;
4141
return Container(
4242
color: GSYColors.primaryValue,
4343
child: new Center(

lib/page/trend/trend_page.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ class TrendPageState extends State<TrendPage>
8484
closedElevation: 0,
8585
transitionType: ContainerTransitionType.fade,
8686
openBuilder: (BuildContext context, VoidCallback _) {
87-
return NavigatorUtils.pageContainer(RepositoryDetailPage(
88-
reposViewModel.ownerName, reposViewModel.repositoryName), context);
87+
return NavigatorUtils.pageContainer(
88+
RepositoryDetailPage(
89+
reposViewModel.ownerName, reposViewModel.repositoryName),
90+
context);
8991
},
9092
tappable: true,
9193
closedBuilder: (BuildContext _, VoidCallback openContainer) {
@@ -213,11 +215,9 @@ class TrendPageState extends State<TrendPage>
213215

214216
///空页面
215217
Widget _buildEmpty() {
216-
var statusBar =
217-
MediaQueryData.fromWindow(WidgetsBinding.instance.window).padding.top;
218-
var bottomArea = MediaQueryData.fromWindow(WidgetsBinding.instance.window)
219-
.padding
220-
.bottom;
218+
var mediaQueryData = MediaQueryData.fromView(View.of(context));
219+
var statusBar = mediaQueryData.padding.top;
220+
var bottomArea = mediaQueryData.padding.bottom;
221221
var height = MediaQuery.of(context).size.height -
222222
statusBar -
223223
bottomArea -

lib/widget/network_cache_image.dart

Lines changed: 0 additions & 157 deletions
This file was deleted.

lib/widget/pull/custom_bouncing_scroll_physics.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CustomBouncingScrollPhysics extends ScrollPhysics {
6666
@override
6767
Simulation? createBallisticSimulation(
6868
ScrollMetrics position, double velocity) {
69-
final Tolerance tolerance = this.tolerance;
69+
final Tolerance tolerance = toleranceFor(position);
7070
if (velocity.abs() >= tolerance.velocity || position.outOfRange) {
7171
return BouncingScrollSimulation(
7272
spring: spring,

0 commit comments

Comments
 (0)