Skip to content

refactor(naked_ui): derive state equality from props - #259

Open
tilucasoli wants to merge 3 commits into
leoafarias/raw-primitives-5-text-magnifierfrom
leoafarias/naked-state-props
Open

tilucasoli wants to merge 3 commits into
leoafarias/raw-primitives-5-text-magnifierfrom
leoafarias/naked-state-props

Conversation

@tilucasoli

@tilucasoli tilucasoli commented Sep 29, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Derives NakedState equality and hashing from props so adding a state field no longer requires separate hand-written equality and hash implementations. All 20 state classes migrate to this convention, with a runtime-type guard and no dependency on Mix.

The collection helper preserves ordered lists and unordered maps/sets. Nested map values and set elements are compared and hashed recursively, so equal independently allocated collections remain findable in hash-based collections.

Only NakedEquatable is exported; the similarly named Mix helpers remain unambiguous. Stacked on #250.

Tests

  • Full Naked UI suite on the equality implementation: 836 passed, 3 default integration skips.
  • Final integrated stack: 39 equality/hash-contract/scrollbar/magnifier regressions and 168 text-field/rendering checks passed. Equality coverage includes nested maps/sets, insertion-order independence, ordered lists, and hash-set lookup.
  • Formatting and diff checks passed. Analysis reports one pre-existing deprecated-toolbar informational diagnostic.

Related Issues

None.

Checklist

  • Tests cover the changed equality/hash contract.
  • The changelog documents subclass migration.
  • Review comments will be followed up.

Breaking Change

  • Yes, for external NakedState subclasses using the removed protected statesEqual/statesHashCode helpers.
  • No.

Move additional equality fields into props => [...super.props, ...]; the base state already includes widget states.

@tilucasoli
tilucasoli added this pull request to stack #251 September 29, 2026 02:00
@tilucasoli
tilucasoli force-pushed the leoafarias/naked-state-props branch 2 times, most recently from 787caaf to 7f50727 Compare September 29, 2026 02:42
Every NakedState subclass hand-wrote `operator ==` and `hashCode`, so a new
field had to be added in three places and was silently dropped from equality
when it was not.

Port Mix's props-based equality into naked_ui as a self-contained copy (the
package keeps no dependency on mix): a DeepCollectionEquality and a
NakedEquatable mixin that derives `==` and `hashCode` from
`List<Object?> get props`. NakedState mixes it in with `props => [states]`,
and subclasses append their own fields.

The propsEquals/propsHash helpers stay unexported because mix exports the
same names and re-exporting them makes those imports ambiguous in remix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tilucasoli
tilucasoli force-pushed the leoafarias/naked-state-props branch from 7f50727 to f645cb6 Compare September 29, 2026 11:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants