Skip to content

chore(supabase_lints): enable avoid-unnecessary-nullable return-type & parameters#1429

Open
spydon wants to merge 3 commits into
chore/enable-avoid-shadowingfrom
chore/enable-nullable-rules
Open

chore(supabase_lints): enable avoid-unnecessary-nullable return-type & parameters#1429
spydon wants to merge 3 commits into
chore/enable-avoid-shadowingfrom
chore/enable-nullable-rules

Conversation

@spydon

@spydon spydon commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Stacked on #1427.

What

Enables avoid-unnecessary-nullable-return-type and avoid-unnecessary-nullable-parameters. Per the v3 split in #1428, this PR only does the non-breaking fixes; genuinely breaking changes stay deferred to v3.

Fixed (9 sites, all non-breaking / internal)

  • storage_client _parseMediaType -> returns non-null MediaType (MediaType.parse never returns null).
  • supabase_flutter _widgetsBindingInstance -> non-null WidgetsBinding; the two callers drop the now-redundant ?. (modern Flutter's WidgetsBinding.instance is non-null).
  • supabase _initSupabaseAuthClient -> required bool autoRefreshToken (the sole caller always passes AuthClientOptions.autoRefreshToken, a non-null bool).
  • supabase + supabase_flutter platform_io.dart: condPlatform / condPlatformVersion / condRuntimeVersion -> non-null. The IO implementation never returns null; the conditional-import stub stays nullable (web can be null), and the public Constants.platform is unchanged (String?).

Inline ignores (2 — nullability is required, not unnecessary)

  • supabase_flutter local_storage_stub.accessToken: the throw-stub must keep String? to match the web implementation (localStorage.getItem is nullable).
  • postgrest _copyWithType's headers parameter: relies on null (the default) to fall back to ?? _headers; making it non-null would change behavior.

Verification

  • dcm analyze packages -> no issues found (including no unused-ignores).
  • dart analyze clean (lib + test) across packages; flutter analyze --fatal-warnings clean.
  • Tests: supabase 83 pass, supabase_flutter 49 pass. (One mock-server stream test flaked on a 30s timeout once, passed on re-run; the platform-metadata test exercising the platform_io change passes.)

Note

The genuinely breaking nullable-related changes are tracked in #1428 (added to the v3 umbrella #1278).

…and parameters

Fix the non-breaking sites and enable both rules:

- _parseMediaType returns a non-null MediaType (parse never returns null).
- _widgetsBindingInstance returns a non-null WidgetsBinding; callers drop
  the now-redundant null-aware access.
- _initSupabaseAuthClient takes a required non-null autoRefreshToken (the
  only caller always passes AuthClientOptions.autoRefreshToken, a bool).
- The platform_io condPlatform/condPlatformVersion/condRuntimeVersion
  getters are non-null (the IO implementation never returns null; the
  stub stays nullable for web).

Two sites keep an inline ignore because their nullability is required:
local_storage_stub.accessToken must match the web implementation's
String?, and _copyWithType's headers parameter relies on null to fall
back to the existing headers.
@spydon spydon requested a review from a team as a code owner June 17, 2026 11:47
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