Unverified Commit aaf1003a authored by Darren Austin's avatar Darren Austin Committed by GitHub

Force the color used by WidgetApp's Title to be fully opaque. (#93267)

parent 7c1eb1bc
......@@ -1631,7 +1631,7 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
assert(title != null, 'onGenerateTitle must return a non-null String');
return Title(
title: title,
color: widget.color,
color: widget.color.withOpacity(1.0),
child: result,
);
},
......@@ -1639,7 +1639,7 @@ class _WidgetsAppState extends State<WidgetsApp> with WidgetsBindingObserver {
} else {
title = Title(
title: widget.title,
color: widget.color,
color: widget.color.withOpacity(1.0),
child: result,
);
}
......
......@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
const Color kTitleColor = Color(0xFF333333);
const String kTitleString = 'Hello World';
Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle }) async {
Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle, Color? color }) async {
await tester.pumpWidget(
WidgetsApp(
supportedLocales: const <Locale>[
......@@ -16,7 +16,7 @@ Future<void> pumpApp(WidgetTester tester, { GenerateAppTitle? onGenerateTitle })
Locale('en', 'GB'),
],
title: kTitleString,
color: kTitleColor,
color: color ?? kTitleColor,
onGenerateTitle: onGenerateTitle,
onGenerateRoute: (RouteSettings settings) {
return PageRouteBuilder<void>(
......@@ -36,6 +36,15 @@ void main() {
expect(tester.widget<Title>(find.byType(Title)).color, kTitleColor);
});
testWidgets('Specified color is made opaque for Title', (WidgetTester tester) async {
// The Title widget can only handle fully opaque colors, the WidgetApp should
// ensure it only uses a fully opaque version of its color for the title.
const Color transparentBlue = Color(0xDD0000ff);
const Color opaqueBlue = Color(0xFF0000ff);
await pumpApp(tester, color: transparentBlue);
expect(tester.widget<Title>(find.byType(Title)).color, opaqueBlue);
});
testWidgets('onGenerateTitle handles changing locales', (WidgetTester tester) async {
String generateTitle(BuildContext context) {
return Localizations.localeOf(context).toString();
......
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