Unverified Commit 4ae5252f authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Fix license page crash (#120728)

parent 911b1378
...@@ -889,7 +889,11 @@ class _PackageLicensePageState extends State<_PackageLicensePage> { ...@@ -889,7 +889,11 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
// A Scrollbar is built-in below. // A Scrollbar is built-in below.
behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false), behavior: ScrollConfiguration.of(context).copyWith(scrollbars: false),
child: Scrollbar( child: Scrollbar(
child: ListView(padding: padding, children: listWidgets), child: ListView(
primary: true,
padding: padding,
children: listWidgets,
),
), ),
), ),
), ),
......
...@@ -913,6 +913,67 @@ void main() { ...@@ -913,6 +913,67 @@ void main() {
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgets('ListView of license entries is primary', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/120710
LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
LicenseEntryWithLineBreaks(
<String>['AAA'],
// Add enough content to scroll
List<String>.generate(500, (int index) => 'BBBB').join('\n'),
),
]);
});
await tester.pumpWidget(
MaterialApp(
title: 'Flutter Code Sample',
home: Scaffold(
body: Builder(
builder: (BuildContext context) => TextButton(
child: const Text('Show License Page'),
onPressed: () {
showLicensePage(context: context);
},
),
),
),
)
);
await tester.pumpAndSettle();
expect(find.text('Show License Page'), findsOneWidget);
await tester.tap(find.text('Show License Page'));
await tester.pumpAndSettle();
// Check for packages.
expect(find.text('AAA'), findsOneWidget);
// Check license is displayed after entering into license page for 'AAA'.
await tester.tap(find.text('AAA'));
await tester.pumpAndSettle();
// The inherited ScrollBehavior should not apply Scrollbars since they are
// already built in to the widget.
switch (debugDefaultTargetPlatformOverride) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.macOS:
case TargetPlatform.windows:
expect(find.byType(CupertinoScrollbar), findsNothing);
break;
case TargetPlatform.iOS:
expect(find.byType(CupertinoScrollbar), findsOneWidget);
break;
case null:
break;
}
expect(find.byType(Scrollbar), findsOneWidget);
expect(find.byType(RawScrollbar), findsNothing);
await tester.drag(find.byType(ListView), const Offset(0.0, 20.0));
await tester.pumpAndSettle(); // No exception triggered.
}, variant: TargetPlatformVariant.all());
testWidgets('LicensePage padding', (WidgetTester tester) async { testWidgets('LicensePage padding', (WidgetTester tester) async {
const FlutterLogo logo = FlutterLogo(); const FlutterLogo logo = FlutterLogo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment