Unverified Commit 60751ca5 authored by Mushaheed Syed's avatar Mushaheed Syed Committed by GitHub

Fix copyWith method of ActionIconThemeData (#126763)

Fixes copyWith method of ActionIconThemeData, now using blank copyWith on [ActionIconThemeData] object that isn't `const ActionIconThemeData()` returns object with same values.

*List which issues are fixed by this PR.*
Fixes https://github.com/flutter/flutter/issues/126762
parent 99464341
......@@ -55,10 +55,10 @@ class ActionIconThemeData with Diagnosticable {
WidgetBuilder? endDrawerButtonIconBuilder,
}) {
return ActionIconThemeData(
backButtonIconBuilder: backButtonIconBuilder ?? backButtonIconBuilder,
closeButtonIconBuilder: closeButtonIconBuilder ?? closeButtonIconBuilder,
drawerButtonIconBuilder: drawerButtonIconBuilder ?? drawerButtonIconBuilder,
endDrawerButtonIconBuilder: endDrawerButtonIconBuilder ?? endDrawerButtonIconBuilder,
backButtonIconBuilder: backButtonIconBuilder ?? this.backButtonIconBuilder,
closeButtonIconBuilder: closeButtonIconBuilder ?? this.closeButtonIconBuilder,
drawerButtonIconBuilder: drawerButtonIconBuilder ?? this.drawerButtonIconBuilder,
endDrawerButtonIconBuilder: endDrawerButtonIconBuilder ?? this.endDrawerButtonIconBuilder,
);
}
......
......@@ -15,6 +15,42 @@ void main() {
const ActionIconThemeData().copyWith().hashCode);
});
testWidgets('ActionIconThemeData copyWith overrides all properties', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/126762.
Widget originalButtonBuilder(BuildContext context) {
return const SizedBox();
}
Widget newButtonBuilder(BuildContext context) {
return const Icon(Icons.add);
}
// Create a ActionIconThemeData with all properties set.
final ActionIconThemeData original = ActionIconThemeData(
backButtonIconBuilder: originalButtonBuilder,
closeButtonIconBuilder: originalButtonBuilder,
drawerButtonIconBuilder: originalButtonBuilder,
endDrawerButtonIconBuilder: originalButtonBuilder,
);
// Check if the all properties are copied.
final ActionIconThemeData copy = original.copyWith();
expect(copy.backButtonIconBuilder, originalButtonBuilder);
expect(copy.closeButtonIconBuilder, originalButtonBuilder);
expect(copy.drawerButtonIconBuilder, originalButtonBuilder);
expect(copy.endDrawerButtonIconBuilder, originalButtonBuilder);
// Check if the properties are overriden.
final ActionIconThemeData overridden = original.copyWith(
backButtonIconBuilder: newButtonBuilder,
closeButtonIconBuilder: newButtonBuilder,
drawerButtonIconBuilder: newButtonBuilder,
endDrawerButtonIconBuilder: newButtonBuilder,
);
expect(overridden.backButtonIconBuilder, newButtonBuilder);
expect(overridden.closeButtonIconBuilder, newButtonBuilder);
expect(overridden.drawerButtonIconBuilder, newButtonBuilder);
expect(overridden.endDrawerButtonIconBuilder, newButtonBuilder);
});
test('ActionIconThemeData defaults', () {
const ActionIconThemeData themeData = ActionIconThemeData();
expect(themeData.backButtonIconBuilder, null);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment