···11+# Nullable `copyWith` Rule
22+33+## Problem
44+55+A common state bug occurs when `copyWith` uses `field ?? this.field` for nullable fields.
66+That pattern cannot distinguish:
77+88+- "keep current value"
99+- "set this field to null"
1010+1111+This breaks flows where `null` is meaningful (for example clearing cursors, `likeUri`, `repostUri`, or `errorMessage`).
1212+1313+## Required Pattern
1414+1515+For nullable fields in immutable state objects, use a sentinel parameter default:
1616+1717+```dart
1818+static const Object _unset = Object();
1919+2020+State copyWith({
2121+ Object? nullableField = _unset,
2222+}) {
2323+ return State(
2424+ nullableField: identical(nullableField, _unset)
2525+ ? this.nullableField
2626+ : nullableField as String?,
2727+ );
2828+}
2929+```
3030+3131+## Where Applied
3232+3333+- `SearchState.copyWith` (cursor and nullable metadata fields)
3434+- `FeedState.copyWith` (cursor and error fields)
3535+- `PostActionState.copyWith` (`likeUri`, `repostUri`, `error`)
3636+3737+## Review Checklist
3838+3939+- If a field is nullable and needs to be clearable, do not use `??` in `copyWith`.
4040+- Add/keep tests that assert nullable fields can be explicitly cleared to `null`.