@@ -138,7 +138,7 @@ class BottomNavigationBar extends StatefulWidget {
138
138
///
139
139
/// If [selectedLabelStyle] .color and [unselectedLabelStyle] .color values
140
140
/// are non-null, they will be used instead of [selectedItemColor] and
141
- /// [unselectedItemColor] .
141
+ /// [unselectedItemColor] to style the label color .
142
142
///
143
143
/// If custom [IconThemeData] s are used, you must provide both
144
144
/// [selectedIconTheme] and [unselectedIconTheme] , and both
@@ -384,7 +384,7 @@ class _BottomNavigationTile extends StatelessWidget {
384
384
this .animation,
385
385
this .iconSize, {
386
386
this .onTap,
387
- this .colorTween ,
387
+ this .itemColorTween ,
388
388
this .flex,
389
389
this .selected = false ,
390
390
required this .selectedLabelStyle,
@@ -410,7 +410,7 @@ class _BottomNavigationTile extends StatelessWidget {
410
410
final Animation <double > animation;
411
411
final double iconSize;
412
412
final VoidCallback ? onTap;
413
- final ColorTween ? colorTween ;
413
+ final ColorTween ? itemColorTween ;
414
414
final double ? flex;
415
415
final bool selected;
416
416
final IconThemeData ? selectedIconTheme;
@@ -513,7 +513,7 @@ class _BottomNavigationTile extends StatelessWidget {
513
513
child: _Tile (
514
514
layout: layout,
515
515
icon: _TileIcon (
516
- colorTween : colorTween ! ,
516
+ itemColorTween : itemColorTween ! ,
517
517
animation: animation,
518
518
iconSize: iconSize,
519
519
selected: selected,
@@ -522,7 +522,7 @@ class _BottomNavigationTile extends StatelessWidget {
522
522
unselectedIconTheme: unselectedIconTheme,
523
523
),
524
524
label: _Label (
525
- colorTween : colorTween ! ,
525
+ itemColorTween : itemColorTween ! ,
526
526
animation: animation,
527
527
item: item,
528
528
selectedLabelStyle: selectedLabelStyle,
@@ -602,7 +602,7 @@ class _Tile extends StatelessWidget {
602
602
603
603
class _TileIcon extends StatelessWidget {
604
604
const _TileIcon ({
605
- required this .colorTween ,
605
+ required this .itemColorTween ,
606
606
required this .animation,
607
607
required this .iconSize,
608
608
required this .selected,
@@ -612,7 +612,7 @@ class _TileIcon extends StatelessWidget {
612
612
}) : assert (selected != null ),
613
613
assert (item != null );
614
614
615
- final ColorTween colorTween ;
615
+ final ColorTween itemColorTween ;
616
616
final Animation <double > animation;
617
617
final double iconSize;
618
618
final bool selected;
@@ -622,7 +622,7 @@ class _TileIcon extends StatelessWidget {
622
622
623
623
@override
624
624
Widget build (BuildContext context) {
625
- final Color ? iconColor = colorTween .evaluate (animation);
625
+ final Color ? iconColor = itemColorTween .evaluate (animation);
626
626
final IconThemeData defaultIconTheme = IconThemeData (
627
627
color: iconColor,
628
628
size: iconSize,
@@ -646,22 +646,22 @@ class _TileIcon extends StatelessWidget {
646
646
647
647
class _Label extends StatelessWidget {
648
648
const _Label ({
649
- required this .colorTween ,
649
+ required this .itemColorTween ,
650
650
required this .animation,
651
651
required this .item,
652
652
required this .selectedLabelStyle,
653
653
required this .unselectedLabelStyle,
654
654
required this .showSelectedLabels,
655
655
required this .showUnselectedLabels,
656
- }) : assert (colorTween != null ),
656
+ }) : assert (itemColorTween != null ),
657
657
assert (animation != null ),
658
658
assert (item != null ),
659
659
assert (selectedLabelStyle != null ),
660
660
assert (unselectedLabelStyle != null ),
661
661
assert (showSelectedLabels != null ),
662
662
assert (showUnselectedLabels != null );
663
663
664
- final ColorTween colorTween ;
664
+ final ColorTween itemColorTween ;
665
665
final Animation <double > animation;
666
666
final BottomNavigationBarItem item;
667
667
final TextStyle selectedLabelStyle;
@@ -679,10 +679,16 @@ class _Label extends StatelessWidget {
679
679
selectedLabelStyle,
680
680
animation.value,
681
681
)! ;
682
+ final ColorTween labelColor = ColorTween (
683
+ begin: unselectedLabelStyle.color
684
+ ?? itemColorTween.begin,
685
+ end: selectedLabelStyle.color
686
+ ?? itemColorTween.end,
687
+ );
682
688
Widget text = DefaultTextStyle .merge (
683
689
style: customStyle.copyWith (
684
690
fontSize: selectedFontSize,
685
- color: colorTween .evaluate (animation),
691
+ color: labelColor .evaluate (animation),
686
692
),
687
693
// The font size should grow here when active, but because of the way
688
694
// font rendering works, it doesn't grow smoothly if we just animate
@@ -923,10 +929,10 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
923
929
break ;
924
930
}
925
931
926
- final ColorTween colorTween ;
932
+ final ColorTween itemColorTween ;
927
933
switch (_effectiveType) {
928
934
case BottomNavigationBarType .fixed:
929
- colorTween = ColorTween (
935
+ itemColorTween = ColorTween (
930
936
begin: widget.unselectedItemColor
931
937
?? bottomTheme.unselectedItemColor
932
938
?? themeData.unselectedWidgetColor,
@@ -937,7 +943,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
937
943
);
938
944
break ;
939
945
case BottomNavigationBarType .shifting:
940
- colorTween = ColorTween (
946
+ itemColorTween = ColorTween (
941
947
begin: widget.unselectedItemColor
942
948
?? bottomTheme.unselectedItemColor
943
949
?? themeData.colorScheme.surface,
@@ -971,7 +977,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
971
977
onTap: () {
972
978
widget.onTap? .call (i);
973
979
},
974
- colorTween : colorTween ,
980
+ itemColorTween : itemColorTween ,
975
981
flex: _evaluateFlex (_animations[i]),
976
982
selected: i == widget.currentIndex,
977
983
showSelectedLabels: widget.showSelectedLabels ?? bottomTheme.showSelectedLabels ?? true ,
0 commit comments