From da7b8327e484f2ce036244bff4880bb771dd636c Mon Sep 17 00:00:00 2001 From: Eilidh Southren Date: Fri, 16 Dec 2022 09:03:40 +0000 Subject: [PATCH] Bottom App Bar M3 background color fix (#117082) * Bottom App Bar M3 background color fix * update test * test update * remove whitespace --- .../lib/src/material/bottom_app_bar.dart | 1 + .../test/material/bottom_app_bar_test.dart | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index 17689af95b..761c53d97b 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -196,6 +196,7 @@ class _BottomAppBarState extends State { key: materialKey, type: isMaterial3 ? MaterialType.canvas : MaterialType.transparency, elevation: elevation, + color: isMaterial3 ? effectiveColor : null, surfaceTintColor: surfaceTintColor, child: child == null ? null diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index d160662afd..554e73a71f 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -197,8 +197,39 @@ void main() { final PhysicalShape physicalShape = tester.widget(find.byType(PhysicalShape).at(0)); + final Material material = tester.widget(find.byType(Material).at(1)); expect(physicalShape.color, const Color(0xff0000ff)); + expect(material.color, null); /* no value in Material 2. */ + }); + + + testWidgets('color overrides theme color with Material 3', (WidgetTester tester) async { + await tester.pumpWidget( + MaterialApp( + theme: ThemeData.light(useMaterial3: true).copyWith( + bottomAppBarColor: const Color(0xffffff00)), + home: Builder( + builder: (BuildContext context) { + return const Scaffold( + floatingActionButton: FloatingActionButton( + onPressed: null, + ), + bottomNavigationBar: BottomAppBar( + color: Color(0xff0000ff), + ), + ); + }, + ), + ), + ); + + final PhysicalShape physicalShape = + tester.widget(find.byType(PhysicalShape).at(0)); + final Material material = tester.widget(find.byType(Material).at(1)); + + expect(physicalShape.color, const Color(0xff0000ff)); + expect(material.color, const Color(0xff0000ff)); }); testWidgets('dark theme applies an elevation overlay color', (WidgetTester tester) async {