Skip to content

Commit

Permalink
适配flutter 3.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed Nov 21, 2023
1 parent 333d690 commit 511a193
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/goods/page/goods_size_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class _GoodsSizePageState extends State<GoodsSizePage> {
)
],
),
Gaps.vGap16,
const Spacer(),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expand Down
3 changes: 0 additions & 3 deletions lib/order/page/order_track_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ class _OrderTrackPageState extends State<OrderTrackPage> {
Stepper(
physics: const BouncingScrollPhysics(),
currentStep: 4 - 1,
// flutter 2.8.0以下使用:
// controlsBuilder: (_, {onStepContinue, onStepCancel}) {
controlsBuilder: (_, __) {
return Gaps.empty; //操作按钮置空
},
Expand Down Expand Up @@ -70,7 +68,6 @@ class _OrderTrackPageState extends State<OrderTrackPage> {
) : Theme.of(context).textTheme.titleSmall),
content: const Text(''),
isActive: index == 0,
// TODO(weilu): 这里的状态图标无法修改,暂时使用原生的。应该可以复制Step代码修改一下。
state: index == 0 ? StepState.complete : StepState.indexed,
);
}
Expand Down
1 change: 1 addition & 0 deletions lib/setting/provider/theme_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ThemeProvider extends ChangeNotifier {

ThemeData getTheme({bool isDarkMode = false}) {
return ThemeData(
useMaterial3: false,
primaryColor: isDarkMode ? Colours.dark_app_main : Colours.app_main,
colorScheme: ColorScheme.fromSwatch().copyWith(
brightness: isDarkMode ? Brightness.dark : Brightness.light,
Expand Down
4 changes: 2 additions & 2 deletions lib/shop/page/freight_config_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ class _FreightConfigPageState extends State<FreightConfigPage> {
const Text('元'),
],
),
Gaps.vGap15,
const Spacer(),
Gaps.line,
Gaps.vGap15,
const Spacer(),
Row(
children: <Widget>[
Semantics(
Expand Down
7 changes: 5 additions & 2 deletions test/goods/goods_accessibility_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter_deer/goods/page/goods_page.dart';
import 'package:flutter_deer/goods/page/goods_search_page.dart';
import 'package:flutter_deer/goods/page/goods_size_edit_page.dart';
import 'package:flutter_deer/goods/page/goods_size_page.dart';
import 'package:flutter_deer/setting/provider/theme_provider.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand All @@ -16,11 +17,12 @@ void main() {
map['goods_size_edit_page'] = const GoodsSizeEditPage();

group('goods => 检测页面可点击目标大小是否大于44 * 44', () {
final ThemeData themeData = ThemeProvider().getTheme();
map.forEach((name, page) {
testWidgets(name, (WidgetTester tester) async {

final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpWidget(MaterialApp(home: page, theme: themeData,));
if (name == 'goods_page') {
// GoodsListPage 内有一个2秒的延时
await tester.pumpAndSettle(const Duration(seconds: 2));
Expand All @@ -32,11 +34,12 @@ void main() {
});

group('goods => 检测页面可点击目标是否都有语义', () {
final ThemeData themeData = ThemeProvider().getTheme();
map.forEach((name, page) {
testWidgets(name, (WidgetTester tester) async {

final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpWidget(MaterialApp(home: page, theme: themeData,));
if (name == 'goods_page') {
await tester.pumpAndSettle(const Duration(seconds: 2));
}
Expand Down
7 changes: 5 additions & 2 deletions test/shop/shop_accessibility_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_deer/setting/provider/theme_provider.dart';
import 'package:flutter_deer/shop/page/freight_config_page.dart';
import 'package:flutter_deer/shop/page/input_text_page.dart';
import 'package:flutter_deer/shop/page/message_page.dart';
Expand All @@ -18,21 +19,23 @@ void main() {
map['freight_config_page'] = const FreightConfigPage();

group('shop => 检测页面可点击目标大小是否大于44 * 44', () {
final ThemeData themeData = ThemeProvider().getTheme();
map.forEach((name, page) {
testWidgets(name, (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpWidget(MaterialApp(home: page, theme: themeData,));
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));
handle.dispose();
}, skip: name == 'select_address_page' || name == 'freight_config_page');
});
});

group('shop => 检测页面可点击目标是否都有语义', () {
final ThemeData themeData = ThemeProvider().getTheme();
map.forEach((name, page) {
testWidgets(name, (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpWidget(MaterialApp(home: page, theme: themeData,));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
Expand Down
7 changes: 5 additions & 2 deletions test/statistics/statistic_accessibility_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_deer/setting/provider/theme_provider.dart';
import 'package:flutter_deer/statistics/page/goods_statistics_page.dart';
import 'package:flutter_deer/statistics/page/order_statistics_page.dart';
import 'package:flutter_deer/statistics/page/statistics_page.dart';
Expand All @@ -12,21 +13,23 @@ void main() {
map['goods_statistics_page'] = const GoodsStatisticsPage();

group('statistics => 检测页面可点击目标大小是否大于44 * 44', () {
final ThemeData themeData = ThemeProvider().getTheme();
map.forEach((name, page) {
testWidgets(name, (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpWidget(MaterialApp(home: page, theme: themeData,));
await expectLater(tester, meetsGuideline(iOSTapTargetGuideline));
handle.dispose();
}, skip: name == 'order_statistics_page');
});
});

group('statistics => 检测页面可点击目标是否都有语义', () {
final ThemeData themeData = ThemeProvider().getTheme();
map.forEach((name, page) {
testWidgets(name, (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(MaterialApp(home: page));
await tester.pumpWidget(MaterialApp(home: page, theme: themeData,));
await expectLater(tester, meetsGuideline(labeledTapTargetGuideline));
handle.dispose();
});
Expand Down
4 changes: 2 additions & 2 deletions test_driver/setting/setting_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main([List<String> args = const <String>[]]) {
await driver.tap(find.text('夜间模式'));
await delayed();
await driver.tap(find.text('开启'));
await Future<dynamic>.delayed(const Duration(seconds: 2));
await Future<dynamic>.delayed(const Duration(seconds: 4));
await driver.tap(find.byTooltip('Back'));
await delayed();
// 查看效果
Expand All @@ -76,7 +76,7 @@ void main([List<String> args = const <String>[]]) {
await driver.tap(find.text('多语言'));
await delayed();
await driver.tap(find.text('English'));
await Future<dynamic>.delayed(const Duration(seconds: 1));
await Future<dynamic>.delayed(const Duration(seconds: 2));
await driver.tap(find.byTooltip('Back'));
await delayed();

Expand Down

0 comments on commit 511a193

Please sign in to comment.