From 5929f4f79baf91cdd6c574a250b9ccae43e7b25e Mon Sep 17 00:00:00 2001 From: Amit Patil <54329870+Amitpatil215@users.noreply.github.com> Date: Wed, 2 Dec 2020 01:13:05 +0530 Subject: [PATCH] updated defualt value of unselectedItemColor textTheme.caption.color to unselectedWidgetColor (#71314) --- .../lib/src/material/bottom_navigation_bar.dart | 5 ++--- .../material/bottom_navigation_bar_test.dart | 16 ++++++++-------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index c3bbbdbaf1..12654e70a1 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -15,7 +15,6 @@ import 'debug.dart'; import 'ink_well.dart'; import 'material.dart'; import 'material_localizations.dart'; -import 'text_theme.dart'; import 'theme.dart'; import 'tooltip.dart'; @@ -267,7 +266,7 @@ class BottomNavigationBar extends StatefulWidget { /// The color of the unselected [BottomNavigationBarItem.icon] and /// [BottomNavigationBarItem.title]s. /// - /// If null then the [TextTheme.caption]'s color is used. + /// If null then the [ThemeData.unselectedWidgetColor]'s color is used. final Color? unselectedItemColor; /// The size, opacity, and color of the icon in the currently selected @@ -853,7 +852,7 @@ class _BottomNavigationBarState extends State with TickerPr colorTween = ColorTween( begin: widget.unselectedItemColor ?? bottomTheme.unselectedItemColor - ?? themeData.textTheme.caption!.color, + ?? themeData.unselectedWidgetColor, end: widget.selectedItemColor ?? bottomTheme.selectedItemColor ?? widget.fixedColor diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index ebce09a454..45be2435cd 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -70,13 +70,13 @@ void main() { testWidgets('Fixed BottomNavigationBar defaults', (WidgetTester tester) async { const Color primaryColor = Color(0xFF000001); - const Color captionColor = Color(0xFF000002); + const Color unselectedWidgetColor = Color(0xFF000002); await tester.pumpWidget( MaterialApp( theme: ThemeData( primaryColor: primaryColor, - textTheme: const TextTheme(caption: TextStyle(color: captionColor)), + unselectedWidgetColor: unselectedWidgetColor, ), home: Scaffold( bottomNavigationBar: BottomNavigationBar( @@ -106,7 +106,7 @@ void main() { expect(selectedFontStyle.fontSize, selectedFontSize); expect(selectedFontStyle.fontWeight, equals(FontWeight.w400)); expect(selectedFontStyle.height, isNull); - expect(unselectedFontStyle.color, equals(captionColor)); + expect(unselectedFontStyle.color, equals(unselectedWidgetColor)); expect(unselectedFontStyle.fontWeight, equals(FontWeight.w400)); expect(unselectedFontStyle.height, isNull); // Unselected label has a font size of 14 but is scaled down to be font size 12. @@ -116,7 +116,7 @@ void main() { ); expect(selectedIcon.color, equals(primaryColor)); expect(selectedIcon.fontSize, equals(24.0)); - expect(unselectedIcon.color, equals(captionColor)); + expect(unselectedIcon.color, equals(unselectedWidgetColor)); expect(unselectedIcon.fontSize, equals(24.0)); // There should not be any [Opacity] or [FadeTransition] widgets // since showUnselectedLabels and showSelectedLabels are true. @@ -439,7 +439,7 @@ void main() { testWidgets('Fixed BottomNavigationBar custom font size, color', (WidgetTester tester) async { const Color primaryColor = Colors.black; - const Color captionColor = Colors.purple; + const Color unselectedWidgetColor = Colors.purple; const Color selectedColor = Colors.blue; const Color unselectedColor = Colors.yellow; const double selectedFontSize = 18.0; @@ -449,7 +449,7 @@ void main() { MaterialApp( theme: ThemeData( primaryColor: primaryColor, - textTheme: const TextTheme(caption: TextStyle(color: captionColor)), + unselectedWidgetColor: unselectedWidgetColor, ), home: Scaffold( bottomNavigationBar: BottomNavigationBar( @@ -499,7 +499,7 @@ void main() { testWidgets('Shifting BottomNavigationBar custom font size, color', (WidgetTester tester) async { const Color primaryColor = Colors.black; - const Color captionColor = Colors.purple; + const Color unselectedWidgetColor = Colors.purple; const Color selectedColor = Colors.blue; const Color unselectedColor = Colors.yellow; const double selectedFontSize = 18.0; @@ -509,7 +509,7 @@ void main() { MaterialApp( theme: ThemeData( primaryColor: primaryColor, - textTheme: const TextTheme(caption: TextStyle(color: captionColor)), + unselectedWidgetColor: unselectedWidgetColor, ), home: Scaffold( bottomNavigationBar: BottomNavigationBar(