Skip to content

Commit

Permalink
适配 3.16
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Nov 22, 2023
1 parent ae033f2 commit 0e64ff0
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

> 目前开始逐步补全完善,主要提供一些有用或者有趣的例子,如果你也有好例子,环境提交 PR 。
>
> **运行须知:配置好Flutter开发环境(目前Flutter SDK 版本 *3.13* 以上版本)。**
> **运行须知:配置好Flutter开发环境(目前Flutter SDK 版本 *3.16* 以上版本)。**
>
> **[如果克隆太慢或者图片看不到,可尝试从码云地址下载](https://gitee.com/CarGuo/GSYFlutterDemo)**
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ class MyApp extends StatelessWidget {
return MaterialApp(
title: 'GSY Flutter Demo',
theme: ThemeData(
useMaterial3: false,
primarySwatch: Colors.blue,
textButtonTheme: TextButtonThemeData(
// 去掉 TextButton 的水波纹效果
Expand Down
1 change: 1 addition & 0 deletions lib/widget/controller_demo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ControllerDemoPage extends StatelessWidget {
Widget build(BuildContext context) {
print("######### MyHomePage ${MediaQuery.of(context).size}");
return Scaffold(
appBar: AppBar(),
body: Container(
alignment: Alignment.center,
child: InkWell(
Expand Down
16 changes: 7 additions & 9 deletions lib/widget/demo_navigator_new.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';



class Book {
final String title;
final String author;
Expand All @@ -17,7 +15,7 @@ class BooksApp extends StatefulWidget {
class _BooksAppState extends State<BooksApp> {
BookRouterDelegate _routerDelegate = BookRouterDelegate();
BookRouteInformationParser _routeInformationParser =
BookRouteInformationParser();
BookRouteInformationParser();

@override
Widget build(BuildContext context) {
Expand All @@ -33,7 +31,7 @@ class BookRouteInformationParser extends RouteInformationParser<BookRoutePath> {
@override
Future<BookRoutePath> parseRouteInformation(
RouteInformation routeInformation) async {
final uri = Uri.parse(routeInformation.location!);
final uri = routeInformation.uri;
// Handle '/'
if (uri.pathSegments.length == 0) {
return BookRoutePath.home();
Expand All @@ -55,13 +53,13 @@ class BookRouteInformationParser extends RouteInformationParser<BookRoutePath> {
@override
RouteInformation? restoreRouteInformation(BookRoutePath path) {
if (path.isUnknown) {
return RouteInformation(location: '/404');
return RouteInformation(uri: Uri.parse('/404'));
}
if (path.isHomePage) {
return RouteInformation(location: '/');
return RouteInformation(uri: Uri.parse('/'));
}
if (path.isDetailsPage) {
return RouteInformation(location: '/book/${path.id}');
return RouteInformation(uri: Uri.parse('/book/${path.id}'));
}
return null;
}
Expand Down Expand Up @@ -232,7 +230,8 @@ class BookDetailsScreen extends StatelessWidget {
children: [
if (book != null) ...[
Text(book!.title, style: Theme.of(context).textTheme.titleLarge),
Text(book!.author, style: Theme.of(context).textTheme.titleMedium),
Text(book!.author,
style: Theme.of(context).textTheme.titleMedium),
],
],
),
Expand All @@ -252,4 +251,3 @@ class UnknownScreen extends StatelessWidget {
);
}
}

2 changes: 1 addition & 1 deletion lib/widget/matrix_custom_painter_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestCustomPainter extends CustomPainter {
ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(
textAlign: TextAlign.center,
fontSize: Theme.of(context).textTheme.displaySmall!.fontSize! *
MediaQuery.textScaleFactorOf(context),
MediaQuery.textScalerOf(context).textScaleFactor,
))
..pushStyle(ui.TextStyle(
color: Colors.white,
Expand Down
17 changes: 8 additions & 9 deletions lib/widget/rich/real_rich_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RealRichText extends Text {
TextDirection? textDirection,
bool softWrap = true,
TextOverflow overflow = TextOverflow.clip,
double textScaleFactor = 1.0,
TextScaler? textScaler,
int? maxLines,
Locale? locale,
}) : super("",
Expand All @@ -57,7 +57,7 @@ class RealRichText extends Text {
textDirection: textDirection,
softWrap: softWrap,
overflow: overflow,
textScaleFactor: textScaleFactor,
textScaler: textScaler,
maxLines: maxLines,
locale: locale);

Expand Down Expand Up @@ -106,8 +106,7 @@ class RealRichText extends Text {
// RichText uses Localizations.localeOf to obtain a default if this is null
softWrap: softWrap ?? defaultTextStyle.softWrap,
overflow: overflow ?? defaultTextStyle.overflow,
textScaleFactor:
textScaleFactor ?? MediaQuery.textScaleFactorOf(context),
textScaler: textScaler ?? MediaQuery.textScalerOf(context),
maxLines: maxLines ?? defaultTextStyle.maxLines,
text: textSpan);
if (semanticsLabel != null) {
Expand Down Expand Up @@ -233,7 +232,7 @@ class _RichTextWrapper extends RichText {
TextDirection? textDirection,
bool softWrap = true,
TextOverflow overflow = TextOverflow.clip,
double textScaleFactor = 1.0,
TextScaler textScaler = TextScaler.noScaling,
int? maxLines,
Locale? locale,
}) : assert(maxLines == null || maxLines > 0),
Expand All @@ -244,7 +243,7 @@ class _RichTextWrapper extends RichText {
textDirection: textDirection,
softWrap: softWrap,
overflow: overflow,
textScaleFactor: textScaleFactor,
textScaler: textScaler,
maxLines: maxLines,
locale: locale);

Expand All @@ -257,7 +256,7 @@ class _RichTextWrapper extends RichText {
textDirection: textDirection ?? Directionality.of(context),
softWrap: softWrap,
overflow: overflow,
textScaleFactor: textScaleFactor,
textScaler: textScaler,
maxLines: maxLines,
locale: locale ?? Localizations.localeOf(context),
);
Expand All @@ -271,7 +270,7 @@ class _RealRichRenderParagraph extends RenderParagraph {
required TextDirection textDirection,
required bool softWrap,
required TextOverflow overflow,
required double textScaleFactor,
required TextScaler textScaler,
int? maxLines,
Locale? locale})
: super(
Expand All @@ -280,7 +279,7 @@ class _RealRichRenderParagraph extends RenderParagraph {
textDirection: textDirection,
softWrap: softWrap,
overflow: overflow,
textScaleFactor: textScaleFactor,
textScaler: textScaler,
maxLines: maxLines,
locale: locale,
);
Expand Down
10 changes: 5 additions & 5 deletions lib/widget/text_size_demo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class TextSizeDemoPage extends StatefulWidget {
}

class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
double textScaleFactor = 1;
TextScaler textScaler = TextScaler.noScaling;

@override
void initState() {
Expand All @@ -18,7 +18,7 @@ class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
return MediaQuery(
data: MediaQueryData.fromView(
WidgetsBinding.instance.platformDispatcher.views.first)
.copyWith(textScaleFactor: textScaleFactor),
.copyWith(textScaler: textScaler),
child: Scaffold(
appBar: AppBar(
title: new Text("TextLineHeightDemoPage"),
Expand All @@ -44,9 +44,9 @@ class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
children: <Widget>[
new TextButton(
onPressed: () {
if (textScaleFactor > 1) {
if (textScaler.textScaleFactor > 1) {
setState(() {
textScaleFactor--;
textScaler.scale(textScaler.textScaleFactor - 1);
});
}
},
Expand All @@ -60,7 +60,7 @@ class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
new TextButton(
onPressed: () {
setState(() {
textScaleFactor++;
textScaler.scale(textScaler.textScaleFactor + 1);
});
},
style: TextButton.styleFrom(
Expand Down
26 changes: 13 additions & 13 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ packages:
dependency: transitive
description:
name: collection
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.17.2"
version: "1.18.0"
convert:
dependency: transitive
description:
Expand Down Expand Up @@ -391,10 +391,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.9.1"
version: "1.10.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -532,18 +532,18 @@ packages:
dependency: transitive
description:
name: stack_trace
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.11.0"
version: "1.11.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
version: "2.1.2"
stream_transform:
dependency: transitive
description:
Expand Down Expand Up @@ -588,10 +588,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.6.0"
version: "0.6.1"
timing:
dependency: transitive
description:
Expand Down Expand Up @@ -628,10 +628,10 @@ packages:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.1.4-beta"
version: "0.3.0"
web_socket_channel:
dependency: transitive
description:
Expand Down Expand Up @@ -666,5 +666,5 @@ packages:
source: git
version: "0.0.1+3"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.0.0"

0 comments on commit 0e64ff0

Please sign in to comment.