Skip to content

chore: adopt null-aware elements now that minimum Dart SDK is 3.9#1531

Open
spydon wants to merge 2 commits into
mainfrom
chore/adopt-null-aware-elements
Open

chore: adopt null-aware elements now that minimum Dart SDK is 3.9#1531
spydon wants to merge 2 commits into
mainfrom
chore/adopt-null-aware-elements

Conversation

@spydon

@spydon spydon commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What

Now that the minimum Dart SDK is 3.9, this adopts the null-aware elements language feature (stabilized in Dart 3.8) across the codebase.

  • Enable the previously SDK-gated prefer-null-aware-elements DCM rule in supabase_lints.
  • Rewrite all 65 flagged collection literals to use null-aware elements (?element) instead of if (x != null) guards:
    • List/set: if (prefer != null) prefer?prefer
    • Map value: if (email != null) 'email': email'email': ?email
    • Guarded chains: if (grantTypes != null) 'grant_types': grantTypes!.map(...)'grant_types': ?grantTypes?.map(...)

Dot shorthands

The config previously claimed the three dot-shorthand rules needed "Dart 3.9". That is inaccurate: dot shorthands are still an experimental language feature and cannot be used by code targeting the 3.9 floor (verified: Color c = .green; still errors at language 3.9 on Dart 3.12). Those rules stay disabled, and their comment is corrected to reflect this.

Verification

  • dcm analyze packages examples → 0 prefer-null-aware-elements violations
  • dart analyze → clean across all touched packages
  • dart format → no reformatting needed
  • realtime_client mock_test.dart passes (including the with filter case that exercises a changed path)

Enable the previously SDK-gated prefer-null-aware-elements DCM rule and
rewrite all collection literals using null-aware elements (?element)
instead of if (x != null) guards.

Keep the dot-shorthand rules disabled and correct their comment: dot
shorthands are still an experimental language feature, not stabilized in
3.9, so code targeting the 3.9 floor cannot use them.
@spydon spydon requested a review from a team as a code owner July 3, 2026 15:17
…e-elements

# Conflicts:
#	packages/realtime_client/lib/src/types.dart

@Vinzent03 Vinzent03 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I immediately thought about the supabase packages when I read the release notes back then. Great to finally make use of it.

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