add missing trailing commas (#81080)
This commit is contained in:
parent
3df0f931fa
commit
80dd6a406a
@ -155,10 +155,8 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
final DefaultTextStyle titleStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
|
||||
'Action Sheet'));
|
||||
final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
|
||||
'An action sheet'));
|
||||
final DefaultTextStyle titleStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, 'Action Sheet'));
|
||||
final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, 'An action sheet'));
|
||||
|
||||
expect(titleStyle.style.fontWeight, FontWeight.w600);
|
||||
expect(messageStyle.style.fontWeight, FontWeight.w400);
|
||||
@ -176,8 +174,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
final DefaultTextStyle titleStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
|
||||
'Action Sheet'));
|
||||
final DefaultTextStyle titleStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, 'Action Sheet'));
|
||||
|
||||
expect(titleStyle.style.fontWeight, FontWeight.w400);
|
||||
});
|
||||
@ -194,8 +191,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle,
|
||||
'An action sheet'));
|
||||
final DefaultTextStyle messageStyle = tester.firstWidget(find.widgetWithText(DefaultTextStyle, 'An action sheet'));
|
||||
|
||||
expect(messageStyle.style.fontWeight, FontWeight.w600);
|
||||
});
|
||||
@ -219,8 +215,10 @@ void main() {
|
||||
|
||||
// Content section should be at the bottom left of action sheet
|
||||
// (minus padding).
|
||||
expect(tester.getBottomLeft(find.byType(ClipRRect)),
|
||||
tester.getBottomLeft(find.byType(CupertinoActionSheet)) - const Offset(-8.0, 10.0));
|
||||
expect(
|
||||
tester.getBottomLeft(find.byType(ClipRRect)),
|
||||
tester.getBottomLeft(find.byType(CupertinoActionSheet)) - const Offset(-8.0, 10.0),
|
||||
);
|
||||
|
||||
// Check that the dialog size is the same as the content section size
|
||||
// (minus padding).
|
||||
@ -268,13 +266,19 @@ void main() {
|
||||
|
||||
// Check that the title/message section is not displayed (action section is
|
||||
// at the top of the action sheet + padding).
|
||||
expect(tester.getTopLeft(finder),
|
||||
tester.getTopLeft(find.byType(CupertinoActionSheet)) + const Offset(8.0, 10.0));
|
||||
expect(
|
||||
tester.getTopLeft(finder),
|
||||
tester.getTopLeft(find.byType(CupertinoActionSheet)) + const Offset(8.0, 10.0),
|
||||
);
|
||||
|
||||
expect(tester.getTopLeft(find.byType(CupertinoActionSheet)) + const Offset(8.0, 10.0),
|
||||
tester.getTopLeft(find.widgetWithText(CupertinoActionSheetAction, 'One')));
|
||||
expect(tester.getBottomLeft(find.byType(CupertinoActionSheet)) + const Offset(8.0, -10.0),
|
||||
tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'Two')));
|
||||
expect(
|
||||
tester.getTopLeft(find.byType(CupertinoActionSheet)) + const Offset(8.0, 10.0),
|
||||
tester.getTopLeft(find.widgetWithText(CupertinoActionSheetAction, 'One')),
|
||||
);
|
||||
expect(
|
||||
tester.getBottomLeft(find.byType(CupertinoActionSheet)) + const Offset(8.0, -10.0),
|
||||
tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'Two')),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Action section is scrollable', (WidgetTester tester) async {
|
||||
@ -474,8 +478,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.getSize(find.byType(CupertinoActionSheet)).height,
|
||||
moreOrLessEquals(132.33333333333334));
|
||||
expect(tester.getSize(find.byType(CupertinoActionSheet)).height, moreOrLessEquals(132.33333333333334));
|
||||
});
|
||||
|
||||
testWidgets('1 action button with cancel button', (WidgetTester tester) async {
|
||||
@ -532,8 +535,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height,
|
||||
moreOrLessEquals(112.33333333333331));
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(112.33333333333331));
|
||||
});
|
||||
|
||||
testWidgets('3 action buttons with cancel button', (WidgetTester tester) async {
|
||||
@ -567,8 +569,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height,
|
||||
moreOrLessEquals(168.66666666666669));
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(168.66666666666669));
|
||||
});
|
||||
|
||||
testWidgets('4+ action buttons with cancel button', (WidgetTester tester) async {
|
||||
@ -606,8 +607,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height,
|
||||
moreOrLessEquals(84.33333333333337));
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(84.33333333333337));
|
||||
});
|
||||
|
||||
testWidgets('1 action button without cancel button', (WidgetTester tester) async {
|
||||
@ -655,8 +655,7 @@ void main() {
|
||||
await tester.tap(find.text('Go'));
|
||||
await tester.pump();
|
||||
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height,
|
||||
moreOrLessEquals(84.33333333333337));
|
||||
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(84.33333333333337));
|
||||
});
|
||||
|
||||
testWidgets('Action sheet with just cancel button is correct', (WidgetTester tester) async {
|
||||
@ -744,8 +743,10 @@ void main() {
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
|
||||
expect(tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'Cancel')).dy, 590.0);
|
||||
expect(tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'One')).dy,
|
||||
moreOrLessEquals(469.66666666666663));
|
||||
expect(
|
||||
tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'One')).dy,
|
||||
moreOrLessEquals(469.66666666666663),
|
||||
);
|
||||
expect(tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'Two')).dy, 526.0);
|
||||
});
|
||||
|
||||
@ -978,7 +979,7 @@ void main() {
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -995,8 +996,8 @@ void main() {
|
||||
}
|
||||
|
||||
RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) {
|
||||
final RenderObject actionsSection = tester.renderObject(find.byElementPredicate(
|
||||
(Element element) {
|
||||
final RenderObject actionsSection = tester.renderObject(
|
||||
find.byElementPredicate((Element element) {
|
||||
return element.widget.runtimeType.toString() == '_CupertinoAlertActionSection';
|
||||
}),
|
||||
);
|
||||
|
@ -9,8 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Activity indicator animate property works',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Activity indicator animate property works', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(buildCupertinoActivityIndicator());
|
||||
expect(SchedulerBinding.instance!.transientCallbackCount, equals(1));
|
||||
|
||||
@ -96,8 +95,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Activity indicator 30% in progress',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Activity indicator 30% in progress', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
@ -119,8 +117,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Activity indicator 100% in progress',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Activity indicator 100% in progress', (WidgetTester tester) async {
|
||||
final Key key = UniqueKey();
|
||||
await tester.pumpWidget(
|
||||
Center(
|
||||
|
@ -10,27 +10,22 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
testWidgets('Heroes work', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home:
|
||||
ListView(
|
||||
children: <Widget>[
|
||||
const Hero(tag: 'a', child: Text('foo')),
|
||||
Builder(builder: (BuildContext context) {
|
||||
return CupertinoButton(
|
||||
child: const Text('next'),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute<void>(
|
||||
builder: (BuildContext context) {
|
||||
return const Hero(tag: 'a', child: Text('foo'));
|
||||
}
|
||||
),
|
||||
);
|
||||
},
|
||||
home: ListView(children: <Widget>[
|
||||
const Hero(tag: 'a', child: Text('foo')),
|
||||
Builder(builder: (BuildContext context) {
|
||||
return CupertinoButton(
|
||||
child: const Text('next'),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
CupertinoPageRoute<void>(builder: (BuildContext context) {
|
||||
return const Hero(tag: 'a', child: Text('foo'));
|
||||
}),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
},
|
||||
);
|
||||
}),
|
||||
]),
|
||||
));
|
||||
|
||||
await tester.tap(find.text('next'));
|
||||
@ -99,17 +94,19 @@ void main() {
|
||||
pageBuilder: (
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return const Text('non-regular page one');
|
||||
}
|
||||
},
|
||||
),
|
||||
PageRouteBuilder<void>(
|
||||
pageBuilder: (
|
||||
BuildContext context,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation) {
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return const Text('non-regular page two');
|
||||
}
|
||||
},
|
||||
),
|
||||
];
|
||||
},
|
||||
@ -118,7 +115,7 @@ void main() {
|
||||
'/': (BuildContext context) => const Text('regular page one'),
|
||||
'/abc': (BuildContext context) => const Text('regular page two'),
|
||||
},
|
||||
)
|
||||
),
|
||||
);
|
||||
expect(find.text('non-regular page two'), findsOneWidget);
|
||||
expect(find.text('non-regular page one'), findsNothing);
|
||||
@ -163,7 +160,7 @@ void main() {
|
||||
location: 'popped',
|
||||
);
|
||||
return route.didPop(result);
|
||||
}
|
||||
},
|
||||
);
|
||||
await tester.pumpWidget(CupertinoApp.router(
|
||||
routeInformationProvider: provider,
|
||||
@ -280,7 +277,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
|
||||
CupertinoPage<void>(
|
||||
key: ValueKey<String?>(routeInformation.location),
|
||||
child: builder(context, routeInformation),
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -433,31 +433,33 @@ Future<void> main() async {
|
||||
final List<int> itemsTapped = <int>[];
|
||||
|
||||
await pumpWidgetWithBoilerplate(
|
||||
tester,
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoTabBar(
|
||||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
label: 'Tab 1',
|
||||
tester,
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoTabBar(
|
||||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
iconProvider,
|
||||
),
|
||||
label: 'Tab 1',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
iconProvider,
|
||||
),
|
||||
],
|
||||
onTap: (int index) => itemsTapped.add(index),
|
||||
),
|
||||
));
|
||||
),
|
||||
],
|
||||
onTap: (int index) => itemsTapped.add(index),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Tab 1'), findsOneWidget);
|
||||
|
||||
final Finder finder = find.byWidgetPredicate(
|
||||
(Widget widget) => widget is Image && widget.image == iconProvider);
|
||||
(Widget widget) => widget is Image && widget.image == iconProvider,
|
||||
);
|
||||
|
||||
await tester.tap(finder);
|
||||
expect(itemsTapped, <int>[1]);
|
||||
@ -465,54 +467,56 @@ Future<void> main() async {
|
||||
|
||||
testWidgets('Hide border hides the top border of the tabBar', (WidgetTester tester) async {
|
||||
await pumpWidgetWithBoilerplate(
|
||||
tester,
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoTabBar(
|
||||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
label: 'Tab 1',
|
||||
tester,
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoTabBar(
|
||||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
label: 'Tab 2',
|
||||
label: 'Tab 1',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
],
|
||||
),
|
||||
));
|
||||
label: 'Tab 2',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final DecoratedBox decoratedBox = tester.widget(find.byType(DecoratedBox));
|
||||
final BoxDecoration boxDecoration = decoratedBox.decoration as BoxDecoration;
|
||||
expect(boxDecoration.border, isNotNull);
|
||||
|
||||
await pumpWidgetWithBoilerplate(
|
||||
tester,
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoTabBar(
|
||||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
label: 'Tab 1',
|
||||
tester,
|
||||
MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoTabBar(
|
||||
items: <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
label: 'Tab 2',
|
||||
label: 'Tab 1',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: ImageIcon(
|
||||
MemoryImage(Uint8List.fromList(kTransparentImage)),
|
||||
),
|
||||
],
|
||||
backgroundColor: const Color(0xFFFFFFFF), // Opaque white.
|
||||
border: null,
|
||||
),
|
||||
));
|
||||
label: 'Tab 2',
|
||||
),
|
||||
],
|
||||
backgroundColor: const Color(0xFFFFFFFF), // Opaque white.
|
||||
border: null,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
final DecoratedBox decoratedBoxHiddenBorder =
|
||||
tester.widget(find.byType(DecoratedBox));
|
||||
|
@ -274,8 +274,8 @@ void main() {
|
||||
)));
|
||||
|
||||
BoxDecoration boxDecoration = tester.widget<DecoratedBox>(
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me')
|
||||
).decoration as BoxDecoration;
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me'),
|
||||
).decoration as BoxDecoration;
|
||||
|
||||
expect(boxDecoration.color, const Color(0x000000FF));
|
||||
|
||||
@ -287,8 +287,8 @@ void main() {
|
||||
)));
|
||||
|
||||
boxDecoration = tester.widget<DecoratedBox>(
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me')
|
||||
).decoration as BoxDecoration;
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me'),
|
||||
).decoration as BoxDecoration;
|
||||
|
||||
expect(boxDecoration.color, const Color(0x0000FF00));
|
||||
});
|
||||
@ -317,7 +317,7 @@ void main() {
|
||||
);
|
||||
|
||||
BoxDecoration boxDecoration = tester.widget<DecoratedBox>(
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me')
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me'),
|
||||
).decoration as BoxDecoration;
|
||||
|
||||
expect(boxDecoration.color!.value, 0xFF654321);
|
||||
@ -335,7 +335,7 @@ void main() {
|
||||
);
|
||||
|
||||
boxDecoration = tester.widget<DecoratedBox>(
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me')
|
||||
find.widgetWithText(DecoratedBox, 'Skeuomorph me'),
|
||||
).decoration as BoxDecoration;
|
||||
|
||||
// Disabled color.
|
||||
|
@ -202,13 +202,15 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Dynamic colors that are not actually dynamic should not claim dependencies',
|
||||
testWidgets(
|
||||
'Dynamic colors that are not actually dynamic should not claim dependencies',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(const DependentWidget(color: notSoDynamicColor1));
|
||||
|
||||
expect(tester.takeException(), null);
|
||||
expect(find.byType(DependentWidget), paints..rect(color: color0));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Dynamic colors that are only dependent on vibrancy should not claim unnecessary dependencies, '
|
||||
@ -251,7 +253,8 @@ void main() {
|
||||
expect(tester.takeException(), null);
|
||||
expect(find.byType(DependentWidget), paints..rect(color: color1));
|
||||
expect(find.byType(DependentWidget), isNot(paints..rect(color: color0)));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Dynamic colors that are only dependent on accessibility contrast should not claim unnecessary dependencies, '
|
||||
@ -279,7 +282,8 @@ void main() {
|
||||
expect(tester.takeException(), null);
|
||||
expect(find.byType(DependentWidget), paints..rect(color: color0));
|
||||
expect(find.byType(DependentWidget), isNot(paints..rect(color: color1)));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Dynamic colors that are only dependent on elevation level should not claim unnecessary dependencies, '
|
||||
@ -307,7 +311,8 @@ void main() {
|
||||
expect(tester.takeException(), null);
|
||||
expect(find.byType(DependentWidget), paints..rect(color: color0));
|
||||
expect(find.byType(DependentWidget), isNot(paints..rect(color: color1)));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Dynamic color with all 3 dependencies works', (WidgetTester tester) async {
|
||||
const Color dynamicRainbowColor1 = CupertinoDynamicColor(
|
||||
@ -422,7 +427,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor as CupertinoDynamicColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -440,7 +445,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor as CupertinoDynamicColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -459,7 +464,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor as CupertinoDynamicColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -481,7 +486,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor as CupertinoDynamicColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -514,7 +519,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -542,7 +547,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -565,7 +570,7 @@ void main() {
|
||||
builder: (BuildContext context) {
|
||||
color = CupertinoTheme.of(context).primaryColor;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -211,9 +211,7 @@ void main() {
|
||||
);
|
||||
|
||||
// Distance between the first column and the last column.
|
||||
final double distance = tester.getCenter(
|
||||
find.text('sec.')).dx - tester.getCenter(find.text('12'),
|
||||
).dx;
|
||||
final double distance = tester.getCenter(find.text('sec.')).dx - tester.getCenter(find.text('12')).dx;
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
@ -693,7 +691,8 @@ void main() {
|
||||
tester.widget<Text>(find.text('29')).style!.color,
|
||||
isSameColorAs(CupertinoColors.inactiveGray.color),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'dateTime picker automatically scrolls away from invalid date, '
|
||||
@ -770,7 +769,8 @@ void main() {
|
||||
date,
|
||||
DateTime(2019, 11, 11, 3, 30),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'time picker automatically scrolls away from invalid date, '
|
||||
@ -847,7 +847,8 @@ void main() {
|
||||
date,
|
||||
DateTime(2019, 11, 11, 3, 30),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('picker automatically scrolls away from invalid date on day change', (WidgetTester tester) async {
|
||||
late DateTime date;
|
||||
@ -933,7 +934,8 @@ void main() {
|
||||
expect(date.year, minDate.year);
|
||||
expect(date.month, minDate.month);
|
||||
expect(date.day, minDate.day);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('date picker does not display previous day of minimumDate if it is set at midnight', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/72932
|
||||
|
@ -207,8 +207,8 @@ void main() {
|
||||
),
|
||||
],
|
||||
),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -290,8 +290,8 @@ void main() {
|
||||
scrollController: scrollController,
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Go'));
|
||||
@ -307,9 +307,7 @@ void main() {
|
||||
|
||||
// Expect the modal dialog box to take all available height.
|
||||
expect(
|
||||
tester.getSize(
|
||||
find.byType(ClipRRect)
|
||||
),
|
||||
tester.getSize(find.byType(ClipRRect)),
|
||||
equals(const Size(310.0, 560.0 - 24.0 * 2)),
|
||||
);
|
||||
|
||||
@ -399,8 +397,8 @@ void main() {
|
||||
actionScrollController: actionScrollController,
|
||||
),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.text('Go'));
|
||||
@ -448,7 +446,7 @@ void main() {
|
||||
actionScrollController: actionScrollController,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -475,8 +473,10 @@ void main() {
|
||||
expect(tester.getTopLeft(find.widgetWithText(CupertinoDialogAction, 'One')).dy, equals(277.5));
|
||||
|
||||
// Check that the button's vertical size is the same.
|
||||
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'One')).height,
|
||||
equals(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Two')).height));
|
||||
expect(
|
||||
tester.getSize(find.widgetWithText(CupertinoDialogAction, 'One')).height,
|
||||
equals(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Two')).height),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Button section is empty, Title section is not empty.', (WidgetTester tester) async {
|
||||
@ -1162,7 +1162,7 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@ -1252,17 +1252,15 @@ RenderBox findActionButtonRenderBoxByTitle(WidgetTester tester, String title) {
|
||||
}
|
||||
|
||||
RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) {
|
||||
final RenderObject actionsSection = tester.renderObject(find.byElementPredicate(
|
||||
(Element element) {
|
||||
return element.widget.runtimeType.toString() == '_CupertinoAlertActionSection';
|
||||
}),
|
||||
);
|
||||
final RenderObject actionsSection = tester.renderObject(find.byElementPredicate((Element element) {
|
||||
return element.widget.runtimeType.toString() == '_CupertinoAlertActionSection';
|
||||
}));
|
||||
assert(actionsSection is RenderBox);
|
||||
return actionsSection as RenderBox;
|
||||
}
|
||||
|
||||
Widget createAppWithButtonThatLaunchesDialog({
|
||||
required WidgetBuilder dialogBuilder
|
||||
required WidgetBuilder dialogBuilder,
|
||||
}) {
|
||||
return MaterialApp(
|
||||
home: Material(
|
||||
@ -1296,10 +1294,10 @@ Widget createAppWithCenteredButton(Widget child) {
|
||||
child: Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: null,
|
||||
child: child
|
||||
child: child,
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -57,10 +57,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
tester.getTopLeft(find.byType(Text)).dx >
|
||||
tester.getTopLeft(find.byType(CupertinoTextField)).dx,
|
||||
true);
|
||||
expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, true);
|
||||
});
|
||||
|
||||
testWidgets('LTR puts child after prefix', (WidgetTester tester) async {
|
||||
@ -81,10 +78,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(
|
||||
tester.getTopLeft(find.byType(Text)).dx >
|
||||
tester.getTopLeft(find.byType(CupertinoTextField)).dx,
|
||||
false);
|
||||
expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, false);
|
||||
});
|
||||
|
||||
testWidgets('Shows error widget', (WidgetTester tester) async {
|
||||
@ -121,8 +115,7 @@ void main() {
|
||||
expect(helper, tester.widget(find.byType(Text)));
|
||||
});
|
||||
|
||||
testWidgets('Shows helper text above error text',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Shows helper text above error text', (WidgetTester tester) async {
|
||||
const Widget helper = Text('Helper');
|
||||
const Widget error = CupertinoActivityIndicator();
|
||||
|
||||
@ -139,13 +132,12 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
tester.getTopLeft(find.byType(CupertinoActivityIndicator)).dy >
|
||||
tester.getTopLeft(find.byType(Text)).dy,
|
||||
true);
|
||||
tester.getTopLeft(find.byType(CupertinoActivityIndicator)).dy > tester.getTopLeft(find.byType(Text)).dy,
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Shows helper in label color and error text in red color',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Shows helper in label color and error text in red color', (WidgetTester tester) async {
|
||||
const Widget helper = Text('Helper');
|
||||
const Widget error = Text('Error');
|
||||
|
||||
|
@ -36,8 +36,7 @@ void main() {
|
||||
expect(find.text('Footer'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Shows long dividers in edge-to-edge section part 1',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -54,15 +53,14 @@ void main() {
|
||||
expect(childrenColumn.children.length, 3);
|
||||
});
|
||||
|
||||
testWidgets('Shows long dividers in edge-to-edge section part 2',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoFormSection(
|
||||
children: <Widget>[
|
||||
CupertinoTextFormFieldRow(),
|
||||
CupertinoTextFormFieldRow()
|
||||
CupertinoTextFormFieldRow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -76,8 +74,7 @@ void main() {
|
||||
expect(childrenColumn.children.length, 5);
|
||||
});
|
||||
|
||||
testWidgets('Does not show long dividers in insetGrouped section part 1',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -95,8 +92,7 @@ void main() {
|
||||
expect(childrenColumn.children.length, 1);
|
||||
});
|
||||
|
||||
testWidgets('Does not show long dividers in insetGrouped section part 2',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
restorationScopeId: 'App',
|
||||
@ -104,7 +100,7 @@ void main() {
|
||||
child: CupertinoFormSection.insetGrouped(
|
||||
children: <Widget>[
|
||||
CupertinoTextFormFieldRow(),
|
||||
CupertinoTextFormFieldRow()
|
||||
CupertinoTextFormFieldRow(),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -141,8 +137,7 @@ void main() {
|
||||
expect(boxDecoration.color, backgroundColor);
|
||||
});
|
||||
|
||||
testWidgets('Setting clipBehavior clips children section',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Setting clipBehavior clips children section', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -157,8 +152,7 @@ void main() {
|
||||
expect(find.byType(ClipRRect), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Not setting clipBehavior does not clip children section',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Not setting clipBehavior does not clip children section', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
|
@ -14,7 +14,7 @@ void main() {
|
||||
IconTheme(data: data, child: Builder(builder: (BuildContext context) {
|
||||
retrieved = IconTheme.of(context);
|
||||
return const SizedBox();
|
||||
}))
|
||||
})),
|
||||
);
|
||||
|
||||
expect(retrieved, data);
|
||||
@ -28,7 +28,7 @@ void main() {
|
||||
retrieved = IconTheme.of(context);
|
||||
return const SizedBox();
|
||||
},
|
||||
)
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -200,7 +200,7 @@ void main() {
|
||||
find.descendant(
|
||||
of: find.byType(CupertinoTabScaffold),
|
||||
matching: find.byType(DecoratedBox),
|
||||
)
|
||||
),
|
||||
).decoration as BoxDecoration;
|
||||
|
||||
expect(tabDecoration.color!.value, backgroundColor.color.value);
|
||||
@ -223,7 +223,7 @@ void main() {
|
||||
find.descendant(
|
||||
of: find.byType(CupertinoTabScaffold),
|
||||
matching: find.byType(DecoratedBox),
|
||||
)
|
||||
),
|
||||
).decoration as BoxDecoration;
|
||||
|
||||
expect(tabDecoration.color!.value, backgroundColor.darkColor.value);
|
||||
|
@ -107,11 +107,11 @@ void main() {
|
||||
),
|
||||
);
|
||||
navigator.currentState!.push<void>(CupertinoPageRoute<void>(
|
||||
builder: (BuildContext context) {
|
||||
return const CupertinoNavigationBar(
|
||||
middle: Text('Page 2'),
|
||||
);
|
||||
}
|
||||
builder: (BuildContext context) {
|
||||
return const CupertinoNavigationBar(
|
||||
middle: Text('Page 2'),
|
||||
);
|
||||
},
|
||||
));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoNavigationBarBackButton), findsOneWidget);
|
||||
@ -206,7 +206,7 @@ void main() {
|
||||
largeTitle: Text('Title'),
|
||||
backgroundColor: Color(0xF0F9F9F9),
|
||||
brightness: Brightness.dark,
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -225,7 +225,7 @@ void main() {
|
||||
largeTitle: Text('Title'),
|
||||
backgroundColor: Color(0xF01D1D1D),
|
||||
brightness: Brightness.light,
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -524,9 +524,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byKey(segmentedControlsKey)).dx, 400.0);
|
||||
// The large title is invisible now.
|
||||
expect(
|
||||
tester.renderObject<RenderAnimatedOpacity>(
|
||||
find.widgetWithText(AnimatedOpacity, 'Title')
|
||||
).opacity.value,
|
||||
tester.renderObject<RenderAnimatedOpacity>(find.widgetWithText(AnimatedOpacity, 'Title')).opacity.value,
|
||||
0.0,
|
||||
);
|
||||
});
|
||||
@ -666,8 +664,8 @@ void main() {
|
||||
),
|
||||
child: Placeholder(),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump();
|
||||
@ -684,8 +682,8 @@ void main() {
|
||||
),
|
||||
child: Placeholder(),
|
||||
);
|
||||
}
|
||||
)
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
await tester.pump();
|
||||
@ -997,9 +995,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('CupertinoNavigationBarBackButton shows an error when manually added outside a route', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoNavigationBarBackButton()
|
||||
);
|
||||
await tester.pumpWidget(const CupertinoNavigationBarBackButton());
|
||||
|
||||
final dynamic exception = tester.takeException();
|
||||
expect(exception, isAssertionError);
|
||||
@ -1217,110 +1213,112 @@ void main() {
|
||||
testWidgets(
|
||||
'CupertinoSliverNavigationBar stretches upon over-scroll and bounces back once over-scroll ends',
|
||||
(WidgetTester tester) async {
|
||||
const Text trailingText = Text('Bar Button');
|
||||
const Text titleText = Text('Large Title');
|
||||
const Text trailingText = Text('Bar Button');
|
||||
const Text titleText = Text('Large Title');
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
trailing: trailingText,
|
||||
largeTitle: titleText,
|
||||
stretch: true,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 1200.0,
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
trailing: trailingText,
|
||||
largeTitle: titleText,
|
||||
stretch: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 1200.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
final Finder trailingTextFinder = find.byWidget(trailingText).first;
|
||||
final Finder titleTextFinder = find.byWidget(titleText).first;
|
||||
final Finder trailingTextFinder = find.byWidget(trailingText).first;
|
||||
final Finder titleTextFinder = find.byWidget(titleText).first;
|
||||
|
||||
final Offset initialTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
final Offset initialTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
|
||||
// Drag for overscroll
|
||||
await tester.drag(find.byType(Scrollable), const Offset(0.0, 150.0));
|
||||
await tester.pump();
|
||||
// Drag for overscroll
|
||||
await tester.drag(find.byType(Scrollable), const Offset(0.0, 150.0));
|
||||
await tester.pump();
|
||||
|
||||
final Offset stretchedTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
final Offset stretchedTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
|
||||
expect(
|
||||
stretchedTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
greaterThan(initialTrailingTextToLargeTitleOffset.dy.abs())
|
||||
);
|
||||
expect(
|
||||
stretchedTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
greaterThan(initialTrailingTextToLargeTitleOffset.dy.abs()),
|
||||
);
|
||||
|
||||
// Ensure overscroll retracts to original size after releasing gesture
|
||||
await tester.pumpAndSettle();
|
||||
// Ensure overscroll retracts to original size after releasing gesture
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final Offset finalTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
final Offset finalTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
|
||||
expect(
|
||||
finalTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
initialTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
);
|
||||
});
|
||||
expect(
|
||||
finalTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
initialTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'CupertinoSliverNavigationBar does not stretch upon over-scroll if stretch parameter is false',
|
||||
(WidgetTester tester) async {
|
||||
const Text trailingText = Text('Bar Button');
|
||||
const Text titleText = Text('Large Title');
|
||||
const Text trailingText = Text('Bar Button');
|
||||
const Text titleText = Text('Large Title');
|
||||
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
trailing: trailingText,
|
||||
largeTitle: titleText,
|
||||
stretch: false,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 1200.0,
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
trailing: trailingText,
|
||||
largeTitle: titleText,
|
||||
stretch: false,
|
||||
),
|
||||
),
|
||||
],
|
||||
SliverToBoxAdapter(
|
||||
child: Container(
|
||||
height: 1200.0,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
final Finder trailingTextFinder = find.byWidget(trailingText).first;
|
||||
final Finder titleTextFinder = find.byWidget(titleText).first;
|
||||
final Finder trailingTextFinder = find.byWidget(trailingText).first;
|
||||
final Finder titleTextFinder = find.byWidget(titleText).first;
|
||||
|
||||
final Offset initialTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
final Offset initialTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
|
||||
// Drag for overscroll
|
||||
await tester.drag(find.byType(Scrollable), const Offset(0.0, 150.0));
|
||||
await tester.pump();
|
||||
// Drag for overscroll
|
||||
await tester.drag(find.byType(Scrollable), const Offset(0.0, 150.0));
|
||||
await tester.pump();
|
||||
|
||||
final Offset stretchedTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
final Offset stretchedTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
|
||||
expect(
|
||||
stretchedTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
initialTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
);
|
||||
expect(
|
||||
stretchedTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
initialTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
);
|
||||
|
||||
// Ensure overscroll is zero after releasing gesture
|
||||
await tester.pumpAndSettle();
|
||||
// Ensure overscroll is zero after releasing gesture
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final Offset finalTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
final Offset finalTrailingTextToLargeTitleOffset = tester.getTopLeft(trailingTextFinder) - tester.getTopLeft(titleTextFinder);
|
||||
|
||||
expect(
|
||||
finalTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
initialTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
);
|
||||
});
|
||||
expect(
|
||||
finalTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
initialTrailingTextToLargeTitleOffset.dy.abs(),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Null NavigationBar border transition', (WidgetTester tester) async {
|
||||
// This is a regression test for https://github.com/flutter/flutter/issues/71389
|
||||
@ -1366,7 +1364,7 @@ void main() {
|
||||
class _ExpectStyles extends StatelessWidget {
|
||||
const _ExpectStyles({
|
||||
required this.color,
|
||||
required this.index
|
||||
required this.index,
|
||||
});
|
||||
|
||||
final Color color;
|
||||
|
@ -179,8 +179,7 @@ void main() {
|
||||
expect(bottomMiddle.text.style!.fontFamily, '.SF Pro Text');
|
||||
expect(bottomMiddle.text.style!.letterSpacing, -0.41);
|
||||
|
||||
checkOpacity(
|
||||
tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977);
|
||||
checkOpacity(tester, flying(tester, find.text('Page 1')).first, 0.9004602432250977);
|
||||
|
||||
// The top back label is styled exactly the same way. But the opacity tweens
|
||||
// are flipped.
|
||||
@ -207,8 +206,7 @@ void main() {
|
||||
expect(topBackLabel.text.style!.fontFamily, '.SF Pro Text');
|
||||
expect(topBackLabel.text.style!.letterSpacing, -0.41);
|
||||
|
||||
checkOpacity(
|
||||
tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692);
|
||||
checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.7630139589309692);
|
||||
});
|
||||
|
||||
testWidgets('Font transitions respect themes', (WidgetTester tester) async {
|
||||
@ -589,8 +587,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
final Finder backChevron = flying(tester,
|
||||
find.text(String.fromCharCode(CupertinoIcons.back.codePoint)));
|
||||
final Finder backChevron = flying(tester, find.text(String.fromCharCode(CupertinoIcons.back.codePoint)));
|
||||
|
||||
expect(
|
||||
backChevron,
|
||||
@ -599,13 +596,11 @@ void main() {
|
||||
);
|
||||
// Come in from the right and fade in.
|
||||
checkOpacity(tester, backChevron, 0.0);
|
||||
expect(
|
||||
tester.getTopLeft(backChevron), const Offset(86.734375, 7.0));
|
||||
expect(tester.getTopLeft(backChevron), const Offset(86.734375, 7.0));
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 150));
|
||||
checkOpacity(tester, backChevron, 0.09497911669313908);
|
||||
expect(
|
||||
tester.getTopLeft(backChevron), const Offset(31.055883467197418, 7.0));
|
||||
expect(tester.getTopLeft(backChevron), const Offset(31.055883467197418, 7.0));
|
||||
});
|
||||
|
||||
testWidgets('First appearance of back chevron fades in from the left in RTL', (WidgetTester tester) async {
|
||||
@ -631,8 +626,7 @@ void main() {
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
final Finder backChevron = flying(tester,
|
||||
find.text(String.fromCharCode(CupertinoIcons.back.codePoint)));
|
||||
final Finder backChevron = flying(tester, find.text(String.fromCharCode(CupertinoIcons.back.codePoint)));
|
||||
|
||||
expect(
|
||||
backChevron,
|
||||
@ -660,8 +654,7 @@ void main() {
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
final Finder backChevrons = flying(tester,
|
||||
find.text(String.fromCharCode(CupertinoIcons.back.codePoint)));
|
||||
final Finder backChevrons = flying(tester, find.text(String.fromCharCode(CupertinoIcons.back.codePoint)));
|
||||
|
||||
expect(
|
||||
backChevrons,
|
||||
@ -887,13 +880,11 @@ void main() {
|
||||
|
||||
await tester.pump(const Duration(milliseconds: 50));
|
||||
|
||||
expect(
|
||||
flying(tester, find.text('A title too long to fit')), findsOneWidget);
|
||||
expect(flying(tester, find.text('A title too long to fit')), findsOneWidget);
|
||||
// Automatically changed to the word 'Back' in the back label.
|
||||
expect(flying(tester, find.text('Back')), findsOneWidget);
|
||||
|
||||
checkOpacity(tester, flying(tester, find.text('A title too long to fit')),
|
||||
0.8833301812410355);
|
||||
checkOpacity(tester, flying(tester, find.text('A title too long to fit')), 0.8833301812410355);
|
||||
checkOpacity(tester, flying(tester, find.text('Back')), 0.0);
|
||||
expect(
|
||||
tester.getTopLeft(flying(tester, find.text('A title too long to fit'))),
|
||||
|
@ -161,8 +161,7 @@ void main() {
|
||||
itemExtent: 15.0,
|
||||
children: const <Widget>[Text('1'), Text('1')],
|
||||
onSelectedItemChanged: (int i) {},
|
||||
selectionOverlay: const CupertinoPickerDefaultSelectionOverlay(
|
||||
background: Color(0x12345678)),
|
||||
selectionOverlay: const CupertinoPickerDefaultSelectionOverlay(background: Color(0x12345678)),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -245,7 +244,9 @@ void main() {
|
||||
arguments: 'HapticFeedbackType.selectionClick',
|
||||
),
|
||||
);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.iOS),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'do not trigger haptic effects on non-iOS devices',
|
||||
@ -279,7 +280,9 @@ void main() {
|
||||
await tester.drag(find.text('0'), const Offset(0.0, -100.0), warnIfMissed: false); // has an IgnorePointer
|
||||
expect(selectedItems, <int>[1]);
|
||||
expect(systemCalls, isEmpty);
|
||||
}, variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform platform) => platform != TargetPlatform.iOS).toSet()));
|
||||
},
|
||||
variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform platform) => platform != TargetPlatform.iOS).toSet()),
|
||||
);
|
||||
|
||||
testWidgets('a drag in between items settles back', (WidgetTester tester) async {
|
||||
final FixedExtentScrollController controller =
|
||||
|
@ -118,7 +118,9 @@ void main() {
|
||||
tester.getTopLeft(find.widgetWithText(SizedBox, '0')),
|
||||
Offset.zero,
|
||||
);
|
||||
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
|
||||
},
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
|
||||
testWidgets('let the builder update as canceled drag scrolls away', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@ -294,7 +296,9 @@ void main() {
|
||||
refreshTriggerPullDistance: 100, // Default value.
|
||||
)));
|
||||
expect(mockHelper.invocations, hasLength(5));
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'refreshing task keeps the sliver expanded forever until completes with error',
|
||||
@ -373,7 +377,9 @@ void main() {
|
||||
errorCount++;
|
||||
},
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets('expanded refreshing sliver scrolls normally', (WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
@ -674,7 +680,9 @@ void main() {
|
||||
refreshTriggerPullDistance: 100, // default value.
|
||||
refreshIndicatorExtent: 60, // default value.
|
||||
)));
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'sliver held in overscroll when task finishes completes normally',
|
||||
@ -724,7 +732,9 @@ void main() {
|
||||
tester.getRect(find.widgetWithText(Center, '0')),
|
||||
const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0),
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'sliver scrolled away when task completes properly removes itself',
|
||||
@ -808,7 +818,9 @@ void main() {
|
||||
tester.getRect(find.widgetWithText(Center, '0')),
|
||||
const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0),
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
"don't do anything unless it can be overscrolled at the start of the list",
|
||||
@ -834,7 +846,9 @@ void main() {
|
||||
await tester.fling(find.byType(SizedBox).first, const Offset(0.0, -200.0), 3000.0, warnIfMissed: false); // IgnorePointer is enabled while scroll is ballistic.
|
||||
|
||||
expect(mockHelper.invocations, isEmpty);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'without an onRefresh, builder is called with arm for one frame then sliver goes away',
|
||||
@ -879,7 +893,9 @@ void main() {
|
||||
tester.getRect(find.widgetWithText(Center, '0')),
|
||||
const Rect.fromLTRB(0.0, 0.0, 800.0, 200.0),
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets('Should not crash when dragged', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@ -907,43 +923,45 @@ void main() {
|
||||
// Test to make sure the refresh sliver's overscroll isn't eaten by the
|
||||
// nav bar sliver https://github.com/flutter/flutter/issues/74516.
|
||||
testWidgets(
|
||||
'properly displays when the refresh sliver is behind the large title nav bar sliver',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
largeTitle: Text('Title'),
|
||||
),
|
||||
CupertinoSliverRefreshControl(
|
||||
builder: mockHelper.builder,
|
||||
),
|
||||
buildAListOfStuff(),
|
||||
],
|
||||
'properly displays when the refresh sliver is behind the large title nav bar sliver',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
slivers: <Widget>[
|
||||
const CupertinoSliverNavigationBar(
|
||||
largeTitle: Text('Title'),
|
||||
),
|
||||
CupertinoSliverRefreshControl(
|
||||
builder: mockHelper.builder,
|
||||
),
|
||||
buildAListOfStuff(),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
final double initialFirstCellY = tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy;
|
||||
final double initialFirstCellY = tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy;
|
||||
|
||||
// Drag down but not enough to trigger the refresh.
|
||||
await tester.drag(find.text('0'), const Offset(0.0, 50.0), touchSlopY: 0);
|
||||
await tester.pump();
|
||||
// Drag down but not enough to trigger the refresh.
|
||||
await tester.drag(find.text('0'), const Offset(0.0, 50.0), touchSlopY: 0);
|
||||
await tester.pump();
|
||||
|
||||
expect(mockHelper.invocations.first, matchesBuilder(
|
||||
refreshState: RefreshIndicatorMode.drag,
|
||||
pulledExtent: 50,
|
||||
refreshTriggerPullDistance: 100, // default value.
|
||||
refreshIndicatorExtent: 60, // default value.
|
||||
));
|
||||
expect(mockHelper.invocations, hasLength(1));
|
||||
expect(mockHelper.invocations.first, matchesBuilder(
|
||||
refreshState: RefreshIndicatorMode.drag,
|
||||
pulledExtent: 50,
|
||||
refreshTriggerPullDistance: 100, // default value.
|
||||
refreshIndicatorExtent: 60, // default value.
|
||||
));
|
||||
expect(mockHelper.invocations, hasLength(1));
|
||||
|
||||
expect(
|
||||
tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy,
|
||||
initialFirstCellY + 50
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
expect(
|
||||
tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy,
|
||||
initialFirstCellY + 50,
|
||||
);
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
}
|
||||
|
||||
void stateMachineTestGroup() {
|
||||
@ -1065,7 +1083,9 @@ void main() {
|
||||
CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))),
|
||||
RefreshIndicatorMode.refresh,
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'goes to done internally as soon as the task finishes',
|
||||
@ -1111,7 +1131,9 @@ void main() {
|
||||
CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))),
|
||||
RefreshIndicatorMode.done,
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'goes back to inactive when retracting back past 10% of arming distance',
|
||||
@ -1168,7 +1190,9 @@ void main() {
|
||||
CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder))),
|
||||
RefreshIndicatorMode.inactive,
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'goes back to inactive if already scrolled away when task completes',
|
||||
@ -1226,7 +1250,9 @@ void main() {
|
||||
tester.getTopLeft(find.widgetWithText(SizedBox, '0')).dy,
|
||||
moreOrLessEquals(-145.0332383665717),
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
"don't have to build any indicators or occupy space during refresh",
|
||||
@ -1274,7 +1300,9 @@ void main() {
|
||||
CupertinoSliverRefreshControl.state(tester.element(find.byType(LayoutBuilder, skipOffstage: false))),
|
||||
RefreshIndicatorMode.inactive,
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
},
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets('buildRefreshIndicator progress', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@ -1386,7 +1414,8 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class FakeBuilder {
|
||||
@ -1411,14 +1440,12 @@ class FakeBuilder {
|
||||
if (refreshIndicatorExtent < 0.0) {
|
||||
throw TestFailure('The refreshIndicatorExtent should never be less than 0.0');
|
||||
}
|
||||
invocations.add(
|
||||
BuilderInvocation(
|
||||
refreshState: refreshState,
|
||||
pulledExtent: pulledExtent,
|
||||
refreshTriggerPullDistance: refreshTriggerPullDistance,
|
||||
refreshIndicatorExtent: refreshIndicatorExtent,
|
||||
)
|
||||
);
|
||||
invocations.add(BuilderInvocation(
|
||||
refreshState: refreshState,
|
||||
pulledExtent: pulledExtent,
|
||||
refreshTriggerPullDistance: refreshTriggerPullDistance,
|
||||
refreshIndicatorExtent: refreshIndicatorExtent,
|
||||
));
|
||||
return refreshIndicator;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ void main() {
|
||||
final RenderParagraph aParagraph = a.renderObject! as RenderParagraph;
|
||||
final RenderParagraph bParagraph = b.renderObject! as RenderParagraph;
|
||||
return aParagraph.text.style!.fontSize!.compareTo(
|
||||
bParagraph.text.style!.fontSize!
|
||||
bParagraph.text.style!.fontSize!,
|
||||
);
|
||||
});
|
||||
|
||||
@ -397,7 +397,7 @@ void main() {
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -501,7 +501,7 @@ void main() {
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -590,7 +590,7 @@ void main() {
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -664,7 +664,7 @@ void main() {
|
||||
return const CupertinoPageScaffold(
|
||||
child: Text('2'),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).push(route2);
|
||||
@ -716,7 +716,7 @@ void main() {
|
||||
return const CupertinoPageScaffold(
|
||||
child: Text('2'),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).push(route2);
|
||||
@ -762,7 +762,7 @@ void main() {
|
||||
return const CupertinoPageScaffold(
|
||||
child: Text('2'),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
tester.state<NavigatorState>(find.byType(Navigator)).push(route2);
|
||||
@ -812,7 +812,7 @@ void main() {
|
||||
return const CupertinoPageScaffold(
|
||||
child: Text('2'),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
navigatorKey.currentState!.push(route2);
|
||||
@ -1025,7 +1025,7 @@ void main() {
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
homeTapCount += 1;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -1044,7 +1044,7 @@ void main() {
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
pageTapCount += 1;
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -1118,9 +1118,9 @@ void main() {
|
||||
child: Hero(
|
||||
tag: 'tag',
|
||||
transitionOnUserGestures: true,
|
||||
child: SizedBox(key: container, height: 150.0, width: 150.0)
|
||||
child: SizedBox(key: container, height: 150.0, width: 150.0),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
},
|
||||
'/page2': (BuildContext context) {
|
||||
@ -1131,12 +1131,12 @@ void main() {
|
||||
child: Hero(
|
||||
tag: 'tag',
|
||||
transitionOnUserGestures: true,
|
||||
child: SizedBox(key: container, height: 150.0, width: 150.0)
|
||||
)
|
||||
child: SizedBox(key: container, height: 150.0, width: 150.0),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
));
|
||||
|
||||
@ -1354,8 +1354,7 @@ void main() {
|
||||
home: Navigator(
|
||||
onGenerateRoute: (RouteSettings settings) {
|
||||
return PageRouteBuilder<dynamic>(
|
||||
pageBuilder: (BuildContext context, Animation<double> _,
|
||||
Animation<double> __) {
|
||||
pageBuilder: (BuildContext context, Animation<double> _, Animation<double> __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
@ -1443,9 +1442,10 @@ void main() {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const SizedBox(),
|
||||
barrierColor: customColor);
|
||||
context: context,
|
||||
builder: (BuildContext context) => const SizedBox(),
|
||||
barrierColor: customColor,
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
);
|
||||
@ -1466,9 +1466,10 @@ void main() {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const Text('Visible'),
|
||||
barrierDismissible: true);
|
||||
context: context,
|
||||
builder: (BuildContext context) => const Text('Visible'),
|
||||
barrierDismissible: true,
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
);
|
||||
@ -1491,9 +1492,10 @@ void main() {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
await showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) => const Text('Visible'),
|
||||
barrierDismissible: false);
|
||||
context: context,
|
||||
builder: (BuildContext context) => const Text('Visible'),
|
||||
barrierDismissible: false,
|
||||
);
|
||||
},
|
||||
child: const Text('tap'),
|
||||
);
|
||||
@ -1530,7 +1532,7 @@ void main() {
|
||||
return true;
|
||||
},
|
||||
transitionDelegate: detector,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
expect(detector.hasTransition, isFalse);
|
||||
@ -1556,7 +1558,7 @@ void main() {
|
||||
return true;
|
||||
},
|
||||
transitionDelegate: detector,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
// There should be no transition because the page has the same key.
|
||||
@ -1584,7 +1586,7 @@ void main() {
|
||||
return true;
|
||||
},
|
||||
transitionDelegate: detector,
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
expect(detector.hasTransition, isFalse);
|
||||
@ -1605,7 +1607,7 @@ void main() {
|
||||
return true;
|
||||
},
|
||||
transitionDelegate: detector,
|
||||
)
|
||||
),
|
||||
);
|
||||
// There should be no transition because the page has the same key.
|
||||
expect(detector.hasTransition, isFalse);
|
||||
@ -1795,7 +1797,7 @@ class TransitionDetector extends DefaultTransitionDelegate<void> {
|
||||
return super.resolve(
|
||||
newPageRouteHistory: newPageRouteHistory,
|
||||
locationToExitingPageRoute: locationToExitingPageRoute,
|
||||
pageRouteToPagelessRoutes: pageRouteToPagelessRoutes
|
||||
pageRouteToPagelessRoutes: pageRouteToPagelessRoutes,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1804,7 +1806,7 @@ Widget buildNavigator({
|
||||
required List<Page<dynamic>> pages,
|
||||
PopPageCallback? onPopPage,
|
||||
GlobalKey<NavigatorState>? key,
|
||||
TransitionDelegate<dynamic>? transitionDelegate
|
||||
TransitionDelegate<dynamic>? transitionDelegate,
|
||||
}) {
|
||||
return MediaQuery(
|
||||
data: MediaQueryData.fromWindow(WidgetsBinding.instance!.window),
|
||||
@ -1812,7 +1814,7 @@ Widget buildNavigator({
|
||||
locale: const Locale('en', 'US'),
|
||||
delegates: const <LocalizationsDelegate<dynamic>>[
|
||||
DefaultCupertinoLocalizations.delegate,
|
||||
DefaultWidgetsLocalizations.delegate
|
||||
DefaultWidgetsLocalizations.delegate,
|
||||
],
|
||||
child: Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
@ -67,7 +67,7 @@ void main() {
|
||||
),
|
||||
child: CupertinoScrollbar(
|
||||
child: ListView(
|
||||
children: const <Widget> [SizedBox(width: 4000, height: 4000)]
|
||||
children: const <Widget>[SizedBox(width: 4000, height: 4000)],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -264,93 +264,100 @@ void main() {
|
||||
await tester.pump(_kScrollbarFadeDuration);
|
||||
});
|
||||
|
||||
testWidgets('When isAlwaysShown is true, must pass a controller or find PrimaryScrollController',
|
||||
(WidgetTester tester) async {
|
||||
Widget viewWithScroll() {
|
||||
return const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData(),
|
||||
child: CupertinoScrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
testWidgets(
|
||||
'When isAlwaysShown is true, must pass a controller or find PrimaryScrollController',
|
||||
(WidgetTester tester) async {
|
||||
Widget viewWithScroll() {
|
||||
return const Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: MediaQueryData(),
|
||||
child: CupertinoScrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
final dynamic exception = tester.takeException();
|
||||
expect(exception, isAssertionError);
|
||||
});
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
final dynamic exception = tester.takeException();
|
||||
expect(exception, isAssertionError);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('When isAlwaysShown is true, must pass a controller or find PrimarySCrollController that is attached to a scroll view',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll() {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoScrollbar(
|
||||
controller: controller,
|
||||
isAlwaysShown: true,
|
||||
child: const SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
testWidgets(
|
||||
'When isAlwaysShown is true, '
|
||||
'must pass a controller or find PrimarySCrollController that is attached to a scroll view',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll() {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: CupertinoScrollbar(
|
||||
controller: controller,
|
||||
isAlwaysShown: true,
|
||||
child: const SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
final dynamic exception = tester.takeException();
|
||||
expect(exception, isAssertionError);
|
||||
});
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
final dynamic exception = tester.takeException();
|
||||
expect(exception, isAssertionError);
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('On first render with isAlwaysShown: true, the thumb shows with PrimaryScrollController', (WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll() {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: PrimaryScrollController(
|
||||
controller: controller,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return const CupertinoScrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: SingleChildScrollView(
|
||||
primary: true,
|
||||
child: SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
testWidgets(
|
||||
'On first render with isAlwaysShown: true, the thumb shows with PrimaryScrollController',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll() {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: PrimaryScrollController(
|
||||
controller: controller,
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
return const CupertinoScrollbar(
|
||||
isAlwaysShown: true,
|
||||
child: SingleChildScrollView(
|
||||
primary: true,
|
||||
child: SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rect());
|
||||
});
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rect());
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('On first render with isAlwaysShown: true, the thumb shows',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('On first render with isAlwaysShown: true, the thumb shows', (WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll() {
|
||||
return Directionality(
|
||||
@ -383,8 +390,7 @@ void main() {
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
});
|
||||
|
||||
testWidgets('On first render with isAlwaysShown: false, the thumb is hidden',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('On first render with isAlwaysShown: false, the thumb is hidden', (WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
Widget viewWithScroll() {
|
||||
return Directionality(
|
||||
@ -414,233 +420,239 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
'With isAlwaysShown: true, fling a scroll. While it is still scrolling, set isAlwaysShown: false. The thumb should not fade out until the scrolling stops.',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = true;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: SingleChildScrollView(
|
||||
'With isAlwaysShown: true, fling a scroll. While it is still scrolling, set isAlwaysShown: false. The thumb should not fade out until the scrolling stops.',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = true;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
child: SingleChildScrollView(
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.fling(
|
||||
find.byType(SingleChildScrollView),
|
||||
const Offset(0.0, -10.0),
|
||||
10,
|
||||
);
|
||||
}
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.fling(
|
||||
find.byType(SingleChildScrollView),
|
||||
const Offset(0.0, -10.0),
|
||||
10,
|
||||
);
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
});
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'With isAlwaysShown: false, set isAlwaysShown: true. The thumb should be always shown directly',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = false;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: SingleChildScrollView(
|
||||
'With isAlwaysShown: false, set isAlwaysShown: true. The thumb should be always shown directly',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = false;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
child: SingleChildScrollView(
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
});
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'With isAlwaysShown: false, fling a scroll. While it is still scrolling, set isAlwaysShown: true. The thumb should not fade even after the scrolling stops',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = false;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: SingleChildScrollView(
|
||||
'With isAlwaysShown: false, fling a scroll. While it is still scrolling, set isAlwaysShown: true. '
|
||||
'The thumb should not fade even after the scrolling stops',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = false;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
child: SingleChildScrollView(
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
await tester.fling(
|
||||
find.byType(SingleChildScrollView),
|
||||
const Offset(0.0, -10.0),
|
||||
10,
|
||||
);
|
||||
}
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
await tester.fling(
|
||||
find.byType(SingleChildScrollView),
|
||||
const Offset(0.0, -10.0),
|
||||
10,
|
||||
);
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pump();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
// Wait for the timer delay to expire.
|
||||
await tester.pump(const Duration(milliseconds: 600)); // _kScrollbarTimeToFade
|
||||
await tester.pumpAndSettle();
|
||||
// Scrollbar thumb is showing after scroll finishes and timer ends.
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
});
|
||||
// Wait for the timer delay to expire.
|
||||
await tester.pump(const Duration(milliseconds: 600)); // _kScrollbarTimeToFade
|
||||
await tester.pumpAndSettle();
|
||||
// Scrollbar thumb is showing after scroll finishes and timer ends.
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
'Toggling isAlwaysShown while not scrolling fades the thumb in/out. This works even when you have never scrolled at all yet',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = true;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: SingleChildScrollView(
|
||||
'Toggling isAlwaysShown while not scrolling fades the thumb in/out. '
|
||||
'This works even when you have never scrolled at all yet',
|
||||
(WidgetTester tester) async {
|
||||
final ScrollController controller = ScrollController();
|
||||
bool isAlwaysShown = true;
|
||||
Widget viewWithScroll() {
|
||||
return StatefulBuilder(
|
||||
builder: (BuildContext context, StateSetter setState) {
|
||||
return Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
child: MediaQuery(
|
||||
data: const MediaQueryData(),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
CupertinoScrollbar(
|
||||
isAlwaysShown: isAlwaysShown,
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
child: SingleChildScrollView(
|
||||
controller: controller,
|
||||
child: const SizedBox(
|
||||
width: 4000.0,
|
||||
height: 4000.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
Positioned(
|
||||
bottom: 10,
|
||||
child: CupertinoButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
isAlwaysShown = !isAlwaysShown;
|
||||
});
|
||||
},
|
||||
child: const Text('change isAlwaysShown'),
|
||||
),
|
||||
),
|
||||
)
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
await tester.pumpWidget(viewWithScroll());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), paints..rrect());
|
||||
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
});
|
||||
await tester.tap(find.byType(CupertinoButton));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byType(CupertinoScrollbar), isNot(paints..rrect()));
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Scrollbar thumb can be dragged with long press - horizontal axis', (WidgetTester tester) async {
|
||||
final ScrollController scrollController = ScrollController();
|
||||
@ -741,7 +753,7 @@ void main() {
|
||||
paints..rrect(
|
||||
color: _kScrollbarColor.color,
|
||||
rrect: RRect.fromLTRBR(794.0, 3.0, 797.0, 359.4, const Radius.circular(1.5)),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
// Tap on the track area below the thumb.
|
||||
@ -757,7 +769,7 @@ void main() {
|
||||
const Rect.fromLTRB(794.0, 240.6, 797.0, 597.0),
|
||||
const Radius.circular(1.5),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
// Tap on the track area above the thumb.
|
||||
@ -770,7 +782,7 @@ void main() {
|
||||
paints..rrect(
|
||||
color: _kScrollbarColor.color,
|
||||
rrect: RRect.fromLTRBR(794.0, 3.0, 797.0, 359.4, const Radius.circular(1.5)),
|
||||
)
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
@ -785,7 +797,7 @@ void main() {
|
||||
isAlwaysShown: true,
|
||||
controller: scrollController,
|
||||
child: const SingleChildScrollView(
|
||||
child: SizedBox(width: 4000.0, height: 4000.0)
|
||||
child: SizedBox(width: 4000.0, height: 4000.0),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
@ -150,8 +150,7 @@ void main() {
|
||||
);
|
||||
|
||||
Text placeholder = tester.widget(find.text('Search'));
|
||||
expect(placeholder.style!.color!.value,
|
||||
CupertinoColors.systemGrey.darkColor.value);
|
||||
expect(placeholder.style!.color!.value, CupertinoColors.systemGrey.darkColor.value);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
@ -165,8 +164,7 @@ void main() {
|
||||
);
|
||||
|
||||
placeholder = tester.widget(find.text('Search'));
|
||||
expect(placeholder.style!.color!.value,
|
||||
CupertinoColors.systemGrey.color.value);
|
||||
expect(placeholder.style!.color!.value, CupertinoColors.systemGrey.color.value);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@ -274,8 +272,7 @@ void main() {
|
||||
|
||||
expect(find.byIcon(CupertinoIcons.xmark_circle_fill), findsOneWidget);
|
||||
|
||||
await tester.enterText(
|
||||
find.byType(CupertinoSearchTextField), 'text input');
|
||||
await tester.enterText(find.byType(CupertinoSearchTextField), 'text input');
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('text input'), findsOneWidget);
|
||||
@ -300,8 +297,7 @@ void main() {
|
||||
|
||||
expect(find.byIcon(CupertinoIcons.xmark_circle_fill), findsNothing);
|
||||
|
||||
await tester.enterText(
|
||||
find.byType(CupertinoSearchTextField), 'text input');
|
||||
await tester.enterText(find.byType(CupertinoSearchTextField), 'text input');
|
||||
await tester.pump();
|
||||
|
||||
expect(find.byIcon(CupertinoIcons.xmark_circle_fill), findsOneWidget);
|
||||
@ -443,8 +439,7 @@ void main() {
|
||||
testWidgets(
|
||||
'custom suffix onTap overrides default clearing behavior',
|
||||
(WidgetTester tester) async {
|
||||
final TextEditingController controller =
|
||||
TextEditingController(text: 'Text');
|
||||
final TextEditingController controller = TextEditingController(text: 'Text');
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -466,8 +461,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('onTap is properly forwarded to the inner text field',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('onTap is properly forwarded to the inner text field', (WidgetTester tester) async {
|
||||
int onTapCallCount = 0;
|
||||
|
||||
// onTap can be null.
|
||||
@ -497,9 +491,7 @@ void main() {
|
||||
expect(onTapCallCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('autocorrect is properly forwarded to the inner text field',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
testWidgets('autocorrect is properly forwarded to the inner text field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Center(
|
||||
@ -514,9 +506,7 @@ void main() {
|
||||
expect(textField.autocorrect, false);
|
||||
});
|
||||
|
||||
testWidgets('enabled is properly forwarded to the inner text field',
|
||||
(WidgetTester tester) async {
|
||||
|
||||
testWidgets('enabled is properly forwarded to the inner text field', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Center(
|
||||
|
@ -218,8 +218,10 @@ void main() {
|
||||
),
|
||||
),
|
||||
);
|
||||
fail('Should not be possible to create segmented control in which '
|
||||
'value is not the key of one of the children widgets');
|
||||
fail(
|
||||
'Should not be possible to create segmented control in which '
|
||||
'value is not the key of one of the children widgets',
|
||||
);
|
||||
} on AssertionError catch (e) {
|
||||
expect(e.toString(), contains('children'));
|
||||
}
|
||||
@ -605,8 +607,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final RenderBox buttonBox = tester.renderObject(
|
||||
find.byKey(const ValueKey<String>('Segmented Control')));
|
||||
final RenderBox buttonBox = tester.renderObject(find.byKey(const ValueKey<String>('Segmented Control')));
|
||||
|
||||
expect(buttonBox.size.height, 400.0);
|
||||
});
|
||||
@ -637,8 +638,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final RenderBox segmentedControl = tester.renderObject(
|
||||
find.byKey(const ValueKey<String>('Segmented Control')));
|
||||
final RenderBox segmentedControl = tester.renderObject(find.byKey(const ValueKey<String>('Segmented Control')));
|
||||
|
||||
// Subtract the 16.0px from each side. Remaining width should be allocated
|
||||
// to each child equally.
|
||||
@ -646,12 +646,9 @@ void main() {
|
||||
|
||||
expect(childWidth, 200.0);
|
||||
|
||||
expect(childWidth,
|
||||
getRenderSegmentedControl(tester).getChildrenAsList()[0].parentData.surroundingRect.width);
|
||||
expect(childWidth,
|
||||
getRenderSegmentedControl(tester).getChildrenAsList()[1].parentData.surroundingRect.width);
|
||||
expect(childWidth,
|
||||
getRenderSegmentedControl(tester).getChildrenAsList()[2].parentData.surroundingRect.width);
|
||||
expect(childWidth, getRenderSegmentedControl(tester).getChildrenAsList()[0].parentData.surroundingRect.width);
|
||||
expect(childWidth, getRenderSegmentedControl(tester).getChildrenAsList()[1].parentData.surroundingRect.width);
|
||||
expect(childWidth, getRenderSegmentedControl(tester).getChildrenAsList()[2].parentData.surroundingRect.width);
|
||||
});
|
||||
|
||||
testWidgets('Width is finite in unbounded space', (WidgetTester tester) async {
|
||||
@ -677,8 +674,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
final RenderBox segmentedControl = tester.renderObject(
|
||||
find.byKey(const ValueKey<String>('Segmented Control')));
|
||||
final RenderBox segmentedControl = tester.renderObject(find.byKey(const ValueKey<String>('Segmented Control')));
|
||||
|
||||
expect(segmentedControl.size.width.isFinite, isTrue);
|
||||
});
|
||||
@ -700,8 +696,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getTopRight(find.text('Child 1')).dx >
|
||||
tester.getTopRight(find.text('Child 2')).dx, isTrue);
|
||||
expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async {
|
||||
@ -814,37 +809,38 @@ void main() {
|
||||
await tester.pump();
|
||||
|
||||
expect(
|
||||
semantics,
|
||||
hasSemantics(
|
||||
TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
TestSemantics.rootChild(
|
||||
label: 'Child 1',
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isInMutuallyExclusiveGroup,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
),
|
||||
TestSemantics.rootChild(
|
||||
label: 'Child 2',
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isInMutuallyExclusiveGroup,
|
||||
SemanticsFlag.isSelected,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
ignoreId: true,
|
||||
ignoreRect: true,
|
||||
ignoreTransform: true,
|
||||
));
|
||||
semantics,
|
||||
hasSemantics(
|
||||
TestSemantics.root(
|
||||
children: <TestSemantics>[
|
||||
TestSemantics.rootChild(
|
||||
label: 'Child 1',
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isInMutuallyExclusiveGroup,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
),
|
||||
TestSemantics.rootChild(
|
||||
label: 'Child 2',
|
||||
flags: <SemanticsFlag>[
|
||||
SemanticsFlag.isButton,
|
||||
SemanticsFlag.isInMutuallyExclusiveGroup,
|
||||
SemanticsFlag.isSelected,
|
||||
],
|
||||
actions: <SemanticsAction>[
|
||||
SemanticsAction.tap,
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
ignoreId: true,
|
||||
ignoreRect: true,
|
||||
ignoreTransform: true,
|
||||
),
|
||||
);
|
||||
|
||||
semantics.dispose();
|
||||
});
|
||||
@ -967,7 +963,8 @@ void main() {
|
||||
await tester.tapAt(centerOfTwo + const Offset(10, 0));
|
||||
|
||||
expect(sharedValue, 1);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Animation is correct when the selected segment changes', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
@ -347,7 +347,7 @@ void main() {
|
||||
TestSemantics(
|
||||
id: 1,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.isSlider],
|
||||
)
|
||||
),
|
||||
],
|
||||
),
|
||||
ignoreRect: true,
|
||||
@ -587,7 +587,7 @@ void main() {
|
||||
..rrect()
|
||||
..rrect()
|
||||
..rrect()
|
||||
..rrect(color: CupertinoColors.systemPurple.color)
|
||||
..rrect(color: CupertinoColors.systemPurple.color),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -610,7 +610,7 @@ void main() {
|
||||
..rrect()
|
||||
..rrect()
|
||||
..rrect()
|
||||
..rrect(color: CupertinoColors.activeOrange.color)
|
||||
..rrect(color: CupertinoColors.activeOrange.color),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
@ -573,8 +573,7 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(tester.getTopRight(find.text('Child 1')).dx >
|
||||
tester.getTopRight(find.text('Child 2')).dx, isTrue);
|
||||
expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async {
|
||||
@ -701,7 +700,8 @@ void main() {
|
||||
ignoreId: true,
|
||||
ignoreRect: true,
|
||||
ignoreTransform: true,
|
||||
));
|
||||
),
|
||||
);
|
||||
|
||||
semantics.dispose();
|
||||
});
|
||||
@ -901,7 +901,8 @@ void main() {
|
||||
// are to account for the thumb's vertical EdgeInsets.
|
||||
expect(segmentedControlOrigin.dx - 1, lessThanOrEqualTo(thumbRect.left));
|
||||
expect(segmentedControlOrigin.dx + renderSegmentedControl.size.width + 1, greaterThanOrEqualTo(thumbRect.right));
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Transition is triggered while a transition is already occurring', (WidgetTester tester) async {
|
||||
const Map<int, Widget> children = <int, Widget>{
|
||||
|
@ -60,7 +60,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -250,7 +250,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -286,7 +286,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -305,7 +305,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -504,7 +504,7 @@ void main() {
|
||||
tabBuilder: (BuildContext context, int index) {
|
||||
contentPadding = MediaQuery.of(context).padding;
|
||||
return const Placeholder();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -514,7 +514,8 @@ void main() {
|
||||
|
||||
expect(await getContentPaddingWithTabBarColor(const Color(0xAAFFFFFF)), isNot(EdgeInsets.zero));
|
||||
expect(await getContentPaddingWithTabBarColor(const Color(0xFFFFFFFF)), EdgeInsets.zero);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Tab and page scaffolds do not double stack view insets', (WidgetTester tester) async {
|
||||
late BuildContext innerContext;
|
||||
@ -631,7 +632,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -653,7 +654,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -670,9 +671,10 @@ void main() {
|
||||
expect(tabsPainted, const <int>[0, 0, 18]);
|
||||
});
|
||||
|
||||
testWidgets('If a controller is initially provided then the parent stops doing so for rebuilds, '
|
||||
'a new instance of CupertinoTabController should be created and used by the widget, '
|
||||
"while preserving the previous controller's tab index",
|
||||
testWidgets(
|
||||
'If a controller is initially provided then the parent stops doing so for rebuilds, '
|
||||
'a new instance of CupertinoTabController should be created and used by the widget, '
|
||||
"while preserving the previous controller's tab index",
|
||||
(WidgetTester tester) async {
|
||||
final List<int> tabsPainted = <int>[];
|
||||
final CupertinoTabController oldController = CupertinoTabController(initialIndex: 0);
|
||||
@ -688,7 +690,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -710,7 +712,7 @@ void main() {
|
||||
return CustomPaint(
|
||||
child: Text('Page ${index + 1}'),
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () { tabsPainted.add(index); }
|
||||
onPaint: () { tabsPainted.add(index); },
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -731,10 +733,12 @@ void main() {
|
||||
|
||||
// Changing [index] of the oldController should not work.
|
||||
expect(tabsPainted, const <int> [0, 0, 1]);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Do not call dispose on a controller that we do not own '
|
||||
'but do remove from its listeners when done listening to it',
|
||||
testWidgets(
|
||||
'Do not call dispose on a controller that we do not own '
|
||||
'but do remove from its listeners when done listening to it',
|
||||
(WidgetTester tester) async {
|
||||
final MockCupertinoTabController mockController = MockCupertinoTabController(initialIndex: 0);
|
||||
|
||||
@ -767,7 +771,8 @@ void main() {
|
||||
|
||||
expect(mockController.numOfListeners, 0);
|
||||
expect(mockController.isDisposed, isFalse);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('The owner can dispose the old controller', (WidgetTester tester) async {
|
||||
CupertinoTabController controller = CupertinoTabController(initialIndex: 2);
|
||||
@ -827,7 +832,7 @@ void main() {
|
||||
tabBuilder: (BuildContext context, int index) {
|
||||
return CustomPaint(
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () => tabsPainted0.add(index)
|
||||
onPaint: () => tabsPainted0.add(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -840,7 +845,7 @@ void main() {
|
||||
tabBuilder: (BuildContext context, int index) {
|
||||
return CustomPaint(
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () => tabsPainted1.add(index)
|
||||
onPaint: () => tabsPainted1.add(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -874,7 +879,7 @@ void main() {
|
||||
tabBuilder: (BuildContext context, int index) {
|
||||
return CustomPaint(
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () => tabsPainted0.add(index)
|
||||
onPaint: () => tabsPainted0.add(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
@ -904,8 +909,8 @@ void main() {
|
||||
tabBuilder: (BuildContext context, int index) {
|
||||
return CustomPaint(
|
||||
painter: TestCallbackPainter(
|
||||
onPaint: () => tabsPainted0.add(index)
|
||||
)
|
||||
onPaint: () => tabsPainted0.add(index),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@ -917,7 +922,8 @@ void main() {
|
||||
expect(tabsPainted0, const <int>[2, 0, 1, 2]);
|
||||
expect(tabsPainted1, const <int>[2, 0]);
|
||||
expect(controller.numOfListeners, 1);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Assert when current tab index >= number of tabs', (WidgetTester tester) async {
|
||||
final CupertinoTabController controller = CupertinoTabController(initialIndex: 2);
|
||||
|
@ -172,8 +172,7 @@ void main() {
|
||||
expect(find.text('second route'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('Throws FlutterError when onUnknownRoute is null', (
|
||||
WidgetTester tester) async {
|
||||
testWidgets('Throws FlutterError when onUnknownRoute is null', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> key = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
@ -191,25 +190,27 @@ void main() {
|
||||
error = e;
|
||||
}
|
||||
expect(error, isNotNull);
|
||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
||||
'FlutterError\n'
|
||||
' Could not find a generator for route RouteSettings("/2", null) in\n'
|
||||
' the _CupertinoTabViewState.\n'
|
||||
' Generators for routes are searched for in the following order:\n'
|
||||
' 1. For the "/" route, the "builder" property, if non-null, is\n'
|
||||
' used.\n'
|
||||
' 2. Otherwise, the "routes" table is used, if it has an entry for\n'
|
||||
' the route.\n'
|
||||
' 3. Otherwise, onGenerateRoute is called. It should return a\n'
|
||||
' non-null value for any valid route not handled by "builder" and\n'
|
||||
' "routes".\n'
|
||||
' 4. Finally if all else fails onUnknownRoute is called.\n'
|
||||
' Unfortunately, onUnknownRoute was not set.\n'
|
||||
));
|
||||
expect(
|
||||
error.toStringDeep(),
|
||||
equalsIgnoringHashCodes(
|
||||
'FlutterError\n'
|
||||
' Could not find a generator for route RouteSettings("/2", null) in\n'
|
||||
' the _CupertinoTabViewState.\n'
|
||||
' Generators for routes are searched for in the following order:\n'
|
||||
' 1. For the "/" route, the "builder" property, if non-null, is\n'
|
||||
' used.\n'
|
||||
' 2. Otherwise, the "routes" table is used, if it has an entry for\n'
|
||||
' the route.\n'
|
||||
' 3. Otherwise, onGenerateRoute is called. It should return a\n'
|
||||
' non-null value for any valid route not handled by "builder" and\n'
|
||||
' "routes".\n'
|
||||
' 4. Finally if all else fails onUnknownRoute is called.\n'
|
||||
' Unfortunately, onUnknownRoute was not set.\n',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Throws FlutterError when onUnknownRoute returns null', (
|
||||
WidgetTester tester) async {
|
||||
testWidgets('Throws FlutterError when onUnknownRoute returns null', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
@ -227,13 +228,16 @@ void main() {
|
||||
error = e;
|
||||
}
|
||||
expect(error, isNotNull);
|
||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
||||
'FlutterError\n'
|
||||
' The onUnknownRoute callback returned null.\n'
|
||||
' When the _CupertinoTabViewState requested the route\n'
|
||||
' RouteSettings("/2", null) from its onUnknownRoute callback, the\n'
|
||||
' callback returned null. Such callbacks must never return null.\n'
|
||||
));
|
||||
expect(
|
||||
error.toStringDeep(),
|
||||
equalsIgnoringHashCodes(
|
||||
'FlutterError\n'
|
||||
' The onUnknownRoute callback returned null.\n'
|
||||
' When the _CupertinoTabViewState requested the route\n'
|
||||
' RouteSettings("/2", null) from its onUnknownRoute callback, the\n'
|
||||
' callback returned null. Such callbacks must never return null.\n',
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Navigator of CupertinoTabView restores state', (WidgetTester tester) async {
|
||||
@ -250,7 +254,7 @@ void main() {
|
||||
),
|
||||
routes: <String, WidgetBuilder>{
|
||||
'/2' : (BuildContext context) => const Text('second route'),
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -35,8 +35,7 @@ class MockClipboard {
|
||||
|
||||
class MockTextSelectionControls extends TextSelectionControls {
|
||||
@override
|
||||
Widget buildHandle(BuildContext context, TextSelectionHandleType type,
|
||||
double textLineHeight) {
|
||||
Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textLineHeight) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@ -107,7 +106,7 @@ class PathBoundsMatcher extends Matcher {
|
||||
final Map<Matcher, dynamic> map = matchState['failedMatcher'] as Map<Matcher, dynamic>;
|
||||
final Iterable<String> descriptions = map.entries
|
||||
.map<String>(
|
||||
(MapEntry<Matcher, dynamic> entry) => entry.key.describeMismatch(entry.value, StringDescription(), matchState, verbose).toString()
|
||||
(MapEntry<Matcher, dynamic> entry) => entry.key.describeMismatch(entry.value, StringDescription(), matchState, verbose).toString(),
|
||||
);
|
||||
|
||||
// description is guaranteed to be non-null.
|
||||
@ -292,7 +291,7 @@ void main() {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoTextField(focusNode: focusNode)
|
||||
home: CupertinoTextField(focusNode: focusNode),
|
||||
),
|
||||
);
|
||||
expect(semantics, hasSemantics(
|
||||
@ -312,9 +311,9 @@ void main() {
|
||||
TestSemantics(
|
||||
id: 4,
|
||||
flags: <SemanticsFlag>[SemanticsFlag.isTextField,
|
||||
SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled],
|
||||
SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled,],
|
||||
actions: <SemanticsAction>[SemanticsAction.tap,
|
||||
SemanticsAction.didGainAccessibilityFocus],
|
||||
SemanticsAction.didGainAccessibilityFocus,],
|
||||
textDirection: TextDirection.ltr,
|
||||
),
|
||||
],
|
||||
@ -1442,7 +1441,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.longPressAt(
|
||||
tester.getTopRight(find.text("j'aime la poutine"))
|
||||
tester.getTopRight(find.text("j'aime la poutine")),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
@ -1473,7 +1472,7 @@ void main() {
|
||||
);
|
||||
|
||||
await tester.longPressAt(
|
||||
tester.getTopRight(find.text("j'aime la poutine"))
|
||||
tester.getTopRight(find.text("j'aime la poutine")),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
@ -1549,7 +1548,7 @@ void main() {
|
||||
expect(tester.testTextInput.hasAnyClients, false);
|
||||
|
||||
await tester.longPressAt(
|
||||
tester.getTopRight(find.text('readonly'))
|
||||
tester.getTopRight(find.text('readonly')),
|
||||
);
|
||||
|
||||
await tester.pump();
|
||||
@ -1590,7 +1589,7 @@ void main() {
|
||||
|
||||
// Tap an area inside the EditableText but with no text.
|
||||
await tester.longPressAt(
|
||||
tester.getTopRight(find.text("j'aime la poutine"))
|
||||
tester.getTopRight(find.text("j'aime la poutine")),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump(const Duration(milliseconds: 200));
|
||||
@ -2348,7 +2347,7 @@ void main() {
|
||||
);
|
||||
|
||||
final RenderEditable renderEditable = tester.renderObject<RenderEditable>(
|
||||
find.byElementPredicate((Element element) => element.renderObject is RenderEditable)
|
||||
find.byElementPredicate((Element element) => element.renderObject is RenderEditable),
|
||||
);
|
||||
|
||||
List<TextSelectionPoint> lastCharEndpoint = renderEditable.getEndpointsForSelection(
|
||||
@ -3024,7 +3023,8 @@ void main() {
|
||||
expect(tapCount, 2);
|
||||
});
|
||||
|
||||
testWidgets('onTap does not work when the text field is disabled',
|
||||
testWidgets(
|
||||
'onTap does not work when the text field is disabled',
|
||||
(WidgetTester tester) async {
|
||||
int tapCount = 0;
|
||||
await tester.pumpWidget(
|
||||
@ -3077,7 +3077,8 @@ void main() {
|
||||
await tester.tap(find.byType(CupertinoTextField), warnIfMissed: false); // disabled
|
||||
await tester.pump();
|
||||
expect(tapCount, 1);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Focus test when the text field is disabled', (WidgetTester tester) async {
|
||||
final FocusNode focusNode = FocusNode();
|
||||
@ -3147,7 +3148,7 @@ void main() {
|
||||
|
||||
expect(
|
||||
tester.renderObject<RenderEditable>(
|
||||
find.byElementPredicate((Element element) => element.renderObject is RenderEditable)
|
||||
find.byElementPredicate((Element element) => element.renderObject is RenderEditable),
|
||||
).text!.style!.color,
|
||||
isSameColorAs(CupertinoColors.white),
|
||||
);
|
||||
@ -4533,7 +4534,7 @@ void main() {
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoTextField(
|
||||
selectionControls: selectionControl
|
||||
selectionControls: selectionControl,
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -4549,7 +4550,7 @@ void main() {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CupertinoTextField(maxLength: 5, inputFormatters: formatters),
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
expect(formatters.isEmpty, isTrue);
|
||||
@ -4677,8 +4678,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('disabled widget changes background color',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('disabled widget changes background color', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Center(
|
||||
@ -4777,5 +4777,6 @@ void main() {
|
||||
),
|
||||
).color;
|
||||
expect(disabledColor, isSameColorAs(const Color(0xFFFAFAFA)));
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import '../rendering/mock_canvas.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Passes textAlign to underlying CupertinoTextField',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Passes textAlign to underlying CupertinoTextField', (WidgetTester tester) async {
|
||||
const TextAlign alignment = TextAlign.center;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -30,8 +29,7 @@ void main() {
|
||||
expect(textFieldWidget.textAlign, alignment);
|
||||
});
|
||||
|
||||
testWidgets('Passes scrollPhysics to underlying TextField',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Passes scrollPhysics to underlying TextField', (WidgetTester tester) async {
|
||||
const ScrollPhysics scrollPhysics = ScrollPhysics();
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -51,8 +49,7 @@ void main() {
|
||||
expect(textFieldWidget.scrollPhysics, scrollPhysics);
|
||||
});
|
||||
|
||||
testWidgets('Passes textAlignVertical to underlying CupertinoTextField',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Passes textAlignVertical to underlying CupertinoTextField', (WidgetTester tester) async {
|
||||
const TextAlignVertical textAlignVertical = TextAlignVertical.bottom;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -72,8 +69,7 @@ void main() {
|
||||
expect(textFieldWidget.textAlignVertical, textAlignVertical);
|
||||
});
|
||||
|
||||
testWidgets('Passes textInputAction to underlying CupertinoTextField',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Passes textInputAction to underlying CupertinoTextField', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -91,8 +87,7 @@ void main() {
|
||||
expect(textFieldWidget.textInputAction, TextInputAction.next);
|
||||
});
|
||||
|
||||
testWidgets('Passes onEditingComplete to underlying CupertinoTextField',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Passes onEditingComplete to underlying CupertinoTextField', (WidgetTester tester) async {
|
||||
void onEditingComplete() {}
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -112,8 +107,7 @@ void main() {
|
||||
expect(textFieldWidget.onEditingComplete, onEditingComplete);
|
||||
});
|
||||
|
||||
testWidgets('Passes cursor attributes to underlying CupertinoTextField',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Passes cursor attributes to underlying CupertinoTextField', (WidgetTester tester) async {
|
||||
const double cursorWidth = 3.14;
|
||||
const double cursorHeight = 6.28;
|
||||
const Radius cursorRadius = Radius.circular(2);
|
||||
@ -141,8 +135,7 @@ void main() {
|
||||
expect(textFieldWidget.cursorColor, cursorColor);
|
||||
});
|
||||
|
||||
testWidgets('onFieldSubmit callbacks are called',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -183,8 +176,7 @@ void main() {
|
||||
expect(_value, 'Soup');
|
||||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -207,8 +199,7 @@ void main() {
|
||||
expect(_validateCalled, 2);
|
||||
});
|
||||
|
||||
testWidgets('validate is called if widget is enabled',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('validate is called if widget is enabled', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -232,8 +223,7 @@ void main() {
|
||||
expect(_validateCalled, 2);
|
||||
});
|
||||
|
||||
testWidgets('readonly text form field will hide cursor by default',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('readonly text form field will hide cursor by default', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -300,8 +290,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/54472.
|
||||
testWidgets('reset resets the text fields value to the initialValue',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('reset resets the text fields value to the initialValue', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoTextFormFieldRow(
|
||||
@ -310,11 +299,9 @@ void main() {
|
||||
),
|
||||
));
|
||||
|
||||
await tester.enterText(
|
||||
find.byType(CupertinoTextFormFieldRow), 'changedValue');
|
||||
await tester.enterText(find.byType(CupertinoTextFormFieldRow), 'changedValue');
|
||||
|
||||
final FormFieldState<String> state = tester
|
||||
.state<FormFieldState<String>>(find.byType(CupertinoTextFormFieldRow));
|
||||
final FormFieldState<String> state = tester.state<FormFieldState<String>>(find.byType(CupertinoTextFormFieldRow));
|
||||
state.reset();
|
||||
|
||||
expect(find.text('changedValue'), findsNothing);
|
||||
@ -322,8 +309,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test for https://github.com/flutter/flutter/issues/54472.
|
||||
testWidgets('didChange changes text fields value',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('didChange changes text fields value', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: Center(
|
||||
child: CupertinoTextFormFieldRow(
|
||||
@ -342,8 +328,7 @@ void main() {
|
||||
expect(find.text('changedValue'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('onChanged callbacks value and FormFieldState.value are sync',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async {
|
||||
bool _called = false;
|
||||
|
||||
late FormFieldState<String> state;
|
||||
@ -382,12 +367,10 @@ void main() {
|
||||
|
||||
final CupertinoTextField widget =
|
||||
tester.widget(find.byType(CupertinoTextField));
|
||||
expect(widget.autofillHints,
|
||||
equals(const <String>[AutofillHints.countryName]));
|
||||
expect(widget.autofillHints, equals(const <String>[AutofillHints.countryName]));
|
||||
});
|
||||
|
||||
testWidgets('autovalidateMode is passed to super',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
|
||||
int _validateCalled = 0;
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -410,8 +393,7 @@ void main() {
|
||||
expect(_validateCalled, 1);
|
||||
});
|
||||
|
||||
testWidgets('AutovalidateMode.always mode shows error from the start',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('AutovalidateMode.always mode shows error from the start', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Center(
|
||||
@ -431,8 +413,7 @@ void main() {
|
||||
expect(errorText.data, 'Error');
|
||||
});
|
||||
|
||||
testWidgets('Shows error text upon invalid input',
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('Shows error text upon invalid input', (WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController(text: '');
|
||||
|
||||
await tester.pumpWidget(
|
||||
|
@ -175,7 +175,8 @@ void main() {
|
||||
expect(
|
||||
setEquals(
|
||||
description,
|
||||
<String>{ 'brightness',
|
||||
<String>{
|
||||
'brightness',
|
||||
'primaryColor',
|
||||
'primaryContrastingColor',
|
||||
'barBackgroundColor',
|
||||
@ -188,7 +189,7 @@ void main() {
|
||||
'navActionTextStyle',
|
||||
'pickerTextStyle',
|
||||
'dateTimePickerTextStyle',
|
||||
}
|
||||
},
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user