Fix lerping for NavigationRailThemeData icon themes (#120066)

* Fix lerping for NavigationRail icon themes

* fix typo
This commit is contained in:
Pierre-Louis 2023-02-10 18:32:43 +01:00 committed by GitHub
parent 5dbd281012
commit f05a555bcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -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,

View File

@ -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);