Add missing [applicationIcon] property to LicensePage widget (#34906)
* Add missing [applicationIcon] property to LicensePage widget
This commit is contained in:
committed by
Shi-Hao Hong
parent
4e973adc79
commit
0e7cfc1e41
@@ -192,6 +192,7 @@ void showLicensePage({
|
||||
builder: (BuildContext context) => LicensePage(
|
||||
applicationName: applicationName,
|
||||
applicationVersion: applicationVersion,
|
||||
applicationIcon: applicationIcon,
|
||||
applicationLegalese: applicationLegalese,
|
||||
)
|
||||
));
|
||||
@@ -275,7 +276,7 @@ class AboutDialog extends StatelessWidget {
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
if (icon != null) IconTheme(data: const IconThemeData(size: 48.0), child: icon),
|
||||
if (icon != null) IconTheme(data: Theme.of(context).iconTheme, child: icon),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24.0),
|
||||
@@ -341,6 +342,7 @@ class LicensePage extends StatefulWidget {
|
||||
Key key,
|
||||
this.applicationName,
|
||||
this.applicationVersion,
|
||||
this.applicationIcon,
|
||||
this.applicationLegalese,
|
||||
}) : super(key: key);
|
||||
|
||||
@@ -357,6 +359,14 @@ class LicensePage extends StatefulWidget {
|
||||
/// Defaults to the empty string.
|
||||
final String applicationVersion;
|
||||
|
||||
/// The icon to show below the application name.
|
||||
///
|
||||
/// By default no icon is shown.
|
||||
///
|
||||
/// Typically this will be an [ImageIcon] widget. It should honor the
|
||||
/// [IconTheme]'s [IconThemeData.size].
|
||||
final Widget applicationIcon;
|
||||
|
||||
/// A string to show in small print.
|
||||
///
|
||||
/// Typically this is a copyright notice.
|
||||
@@ -455,6 +465,7 @@ class _LicensePageState extends State<LicensePage> {
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
final String name = widget.applicationName ?? _defaultApplicationName(context);
|
||||
final String version = widget.applicationVersion ?? _defaultApplicationVersion(context);
|
||||
final Widget icon = widget.applicationIcon ?? _defaultApplicationIcon(context);
|
||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
@@ -474,6 +485,7 @@ class _LicensePageState extends State<LicensePage> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0),
|
||||
children: <Widget>[
|
||||
Text(name, style: Theme.of(context).textTheme.headline, textAlign: TextAlign.center),
|
||||
if (icon != null) IconTheme(data: Theme.of(context).iconTheme, child: icon),
|
||||
Text(version, style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center),
|
||||
Container(height: 18.0),
|
||||
Text(widget.applicationLegalese ?? '', style: Theme.of(context).textTheme.caption, textAlign: TextAlign.center),
|
||||
|
||||
@@ -14,6 +14,8 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('AboutListTile control test', (WidgetTester tester) async {
|
||||
const FlutterLogo logo = FlutterLogo();
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
title: 'Pirate app',
|
||||
@@ -26,7 +28,7 @@ void main() {
|
||||
children: const <Widget>[
|
||||
AboutListTile(
|
||||
applicationVersion: '0.1.2',
|
||||
applicationIcon: FlutterLogo(),
|
||||
applicationIcon: logo,
|
||||
applicationLegalese: 'I am the very model of a modern major general.',
|
||||
aboutBoxChildren: <Widget>[
|
||||
Text('About box'),
|
||||
@@ -41,6 +43,11 @@ void main() {
|
||||
|
||||
expect(find.text('About Pirate app'), findsNothing);
|
||||
expect(find.text('0.1.2'), findsNothing);
|
||||
expect(find.byWidget(logo), findsNothing);
|
||||
expect(
|
||||
find.text('I am the very model of a modern major general.'),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('About box'), findsNothing);
|
||||
|
||||
await tester.tap(find.byType(IconButton));
|
||||
@@ -48,6 +55,11 @@ void main() {
|
||||
|
||||
expect(find.text('About Pirate app'), findsOneWidget);
|
||||
expect(find.text('0.1.2'), findsNothing);
|
||||
expect(find.byWidget(logo), findsNothing);
|
||||
expect(
|
||||
find.text('I am the very model of a modern major general.'),
|
||||
findsNothing,
|
||||
);
|
||||
expect(find.text('About box'), findsNothing);
|
||||
|
||||
await tester.tap(find.text('About Pirate app'));
|
||||
@@ -55,17 +67,29 @@ void main() {
|
||||
|
||||
expect(find.text('About Pirate app'), findsOneWidget);
|
||||
expect(find.text('0.1.2'), findsOneWidget);
|
||||
expect(find.byWidget(logo), findsOneWidget);
|
||||
expect(
|
||||
find.text('I am the very model of a modern major general.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('About box'), findsOneWidget);
|
||||
|
||||
LicenseRegistry.addLicense(() {
|
||||
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
|
||||
const LicenseEntryWithLineBreaks(<String>[ 'Pirate package '], 'Pirate license'),
|
||||
const LicenseEntryWithLineBreaks(<String>['Pirate package '], 'Pirate license'),
|
||||
]);
|
||||
});
|
||||
|
||||
await tester.tap(find.text('VIEW LICENSES'));
|
||||
await tester.pumpAndSettle(const Duration(milliseconds: 100));
|
||||
|
||||
expect(find.text('Pirate app'), findsOneWidget);
|
||||
expect(find.text('0.1.2'), findsOneWidget);
|
||||
expect(find.byWidget(logo), findsOneWidget);
|
||||
expect(
|
||||
find.text('I am the very model of a modern major general.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Pirate license'), findsOneWidget);
|
||||
}, skip: isBrowser);
|
||||
|
||||
@@ -79,7 +103,7 @@ void main() {
|
||||
expect(find.text('About flutter_tester'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('AboutListTile control test', (WidgetTester tester) async {
|
||||
testWidgets('LicensePage control test', (WidgetTester tester) async {
|
||||
LicenseRegistry.addLicense(() {
|
||||
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
|
||||
const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'),
|
||||
@@ -88,7 +112,10 @@ void main() {
|
||||
|
||||
LicenseRegistry.addLicense(() {
|
||||
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
|
||||
const LicenseEntryWithLineBreaks(<String>['Another package'], 'Another license'),
|
||||
const LicenseEntryWithLineBreaks(
|
||||
<String>['Another package'],
|
||||
'Another license',
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -113,6 +140,67 @@ void main() {
|
||||
expect(find.text('Another license'), findsOneWidget);
|
||||
}, skip: isBrowser);
|
||||
|
||||
testWidgets('LicensePage control test with all properties', (WidgetTester tester) async {
|
||||
const FlutterLogo logo = FlutterLogo();
|
||||
|
||||
LicenseRegistry.addLicense(() {
|
||||
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
|
||||
const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'),
|
||||
]);
|
||||
});
|
||||
|
||||
LicenseRegistry.addLicense(() {
|
||||
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
|
||||
const LicenseEntryWithLineBreaks(
|
||||
<String>['Another package'],
|
||||
'Another license',
|
||||
),
|
||||
]);
|
||||
});
|
||||
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
title: 'Pirate app',
|
||||
home: Center(
|
||||
child: LicensePage(
|
||||
applicationName: 'LicensePage test app',
|
||||
applicationVersion: '0.1.2',
|
||||
applicationIcon: logo,
|
||||
applicationLegalese: 'I am the very model of a modern major general.',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Pirate app'), findsNothing);
|
||||
expect(find.text('LicensePage test app'), findsOneWidget);
|
||||
expect(find.text('0.1.2'), findsOneWidget);
|
||||
expect(find.byWidget(logo), findsOneWidget);
|
||||
expect(
|
||||
find.text('I am the very model of a modern major general.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('AAA'), findsNothing);
|
||||
expect(find.text('BBB'), findsNothing);
|
||||
expect(find.text('Another package'), findsNothing);
|
||||
expect(find.text('Another license'), findsNothing);
|
||||
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Pirate app'), findsNothing);
|
||||
expect(find.text('LicensePage test app'), findsOneWidget);
|
||||
expect(find.text('0.1.2'), findsOneWidget);
|
||||
expect(find.byWidget(logo), findsOneWidget);
|
||||
expect(
|
||||
find.text('I am the very model of a modern major general.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('AAA'), findsOneWidget);
|
||||
expect(find.text('BBB'), findsOneWidget);
|
||||
expect(find.text('Another package'), findsOneWidget);
|
||||
expect(find.text('Another license'), findsOneWidget);
|
||||
}, skip: isBrowser);
|
||||
|
||||
testWidgets('LicensePage respects the notch', (WidgetTester tester) async {
|
||||
const double safeareaPadding = 27.0;
|
||||
|
||||
@@ -187,6 +275,16 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
expect(licenseEntry.paragraphsCalled, true);
|
||||
}, skip: isBrowser);
|
||||
|
||||
testWidgets('LicensePage logic defaults to executable name for app name', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
title: 'flutter_tester',
|
||||
home: Material(child: LicensePage()),
|
||||
),
|
||||
);
|
||||
expect(find.text('flutter_tester'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
||||
class FakeLicenseEntry extends LicenseEntry {
|
||||
|
||||
Reference in New Issue
Block a user