From f9b3a2eda77986f1d7867eee411db3efda357f73 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Sun, 9 Aug 2026 14:24:09 -0400 Subject: [PATCH] fix(remix): make checkbox styles value-comparable Closes #121 --- .../lib/src/components/checkbox/checkbox_style.dart | 13 ++++++------- .../components/checkbox/checkbox_style_test.dart | 12 ++++++++++++ 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 packages/remix_fortal/test/components/checkbox/checkbox_style_test.dart diff --git a/packages/remix/lib/src/components/checkbox/checkbox_style.dart b/packages/remix/lib/src/components/checkbox/checkbox_style.dart index 0093a365..241a2da7 100644 --- a/packages/remix/lib/src/components/checkbox/checkbox_style.dart +++ b/packages/remix/lib/src/components/checkbox/checkbox_style.dart @@ -1,5 +1,10 @@ part of 'checkbox.dart'; +final _onIndeterminateVariant = ContextVariant( + 'on_indeterminate', + (context) => NakedCheckboxState.maybeOf(context)?.isChecked == null, +); + /// Style configuration for [RemixCheckbox] container and indicator icon. extension RemixCheckboxStylerRemixHelpers on CheckboxStyler { /// Sets indicator color. @@ -8,13 +13,7 @@ extension RemixCheckboxStylerRemixHelpers on CheckboxStyler { } CheckboxStyler onIndeterminate(CheckboxStyler value) { - return variant( - ContextVariant( - 'on_indeterminate', - (context) => NakedCheckboxState.maybeOf(context)?.isChecked == null, - ), - value, - ); + return variant(_onIndeterminateVariant, value); } /// Sets checkbox fill color on the container. diff --git a/packages/remix_fortal/test/components/checkbox/checkbox_style_test.dart b/packages/remix_fortal/test/components/checkbox/checkbox_style_test.dart new file mode 100644 index 00000000..d1136f04 --- /dev/null +++ b/packages/remix_fortal/test/components/checkbox/checkbox_style_test.dart @@ -0,0 +1,12 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:remix_fortal/remix_fortal.dart'; + +void main() { + test('same arguments produce equal styles', () { + final first = fortalCheckboxStyle(); + final second = fortalCheckboxStyle(); + + expect(first, equals(second)); + expect(first.hashCode, equals(second.hashCode)); + }); +}