Skip to content

Commit

Permalink
Fix lerping for NavigationRailThemeData icon themes (#120066)
Browse files Browse the repository at this point in the history
* Fix lerping for NavigationRail icon themes

* fix typo
  • Loading branch information
guidezpl authored Feb 10, 2023
1 parent 5dbd281 commit f05a555
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/flutter/lib/src/material/navigation_rail_theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ class NavigationRailThemeData with Diagnosticable {
elevation: lerpDouble(a?.elevation, b?.elevation, t),
unselectedLabelTextStyle: TextStyle.lerp(a?.unselectedLabelTextStyle, b?.unselectedLabelTextStyle, t),
selectedLabelTextStyle: TextStyle.lerp(a?.selectedLabelTextStyle, b?.selectedLabelTextStyle, t),
unselectedIconTheme: IconThemeData.lerp(a?.unselectedIconTheme, b?.unselectedIconTheme, t),
selectedIconTheme: IconThemeData.lerp(a?.selectedIconTheme, b?.selectedIconTheme, t),
unselectedIconTheme: a?.unselectedIconTheme == null && b?.unselectedIconTheme == null
? null : IconThemeData.lerp(a?.unselectedIconTheme, b?.unselectedIconTheme, t),
selectedIconTheme: a?.selectedIconTheme == null && b?.selectedIconTheme == null
? null : IconThemeData.lerp(a?.selectedIconTheme, b?.selectedIconTheme, t),
groupAlignment: lerpDouble(a?.groupAlignment, b?.groupAlignment, t),
labelType: t < 0.5 ? a?.labelType : b?.labelType,
useIndicator: t < 0.5 ? a?.useIndicator : b?.useIndicator,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ void main() {
expect(_indicatorDecoration(tester)?.color, indicatorColor);
});

// Regression test for https://github.com/flutter/flutter/issues/118618.
testWidgets('NavigationRailThemeData lerps correctly with null iconThemes', (WidgetTester tester) async {
final NavigationRailThemeData lerp = NavigationRailThemeData.lerp(const NavigationRailThemeData(), const NavigationRailThemeData(), 0.5)!;

expect(lerp.selectedIconTheme, isNull);
expect(lerp.unselectedIconTheme, isNull);
});

testWidgets('Default debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const NavigationRailThemeData().debugFillProperties(builder);
Expand Down

0 comments on commit f05a555

Please sign in to comment.