Skip to content

fix(network_info_plus): Return null for Linux subnet mask and broadcast when IPv4 data is missing - #3982

Merged
vbuberen merged 5 commits into
mainfrom
network_info_plus_linux_null_subnet
Sep 29, 2026
Merged

vbuberen merged 5 commits into
mainfrom
network_info_plus_linux_null_subnet

Conversation

@vbuberen

Copy link
Copy Markdown
Collaborator

Description

On Linux, _getSubnetMask did data?.firstOrNull?['prefix'] as int. When there is no primary connection, no ip4Config, or empty addressData, this casts null to int and throws a TypeError, so getWifiSubmask() and getWifiBroadcast() threw instead of returning null as their Future<String?> signature promises.

Changes:

  • _getSubnetMask reads the prefix as int? and returns null when it is missing.
  • _getBroadcast returns null when either the address or the mask is missing, instead of computing a bogus broadcast from ?? 0 fallbacks.
  • Added tests with fake NetworkManagerClient / NetworkManagerActiveConnection / NetworkManagerIP4Config covering primaryConnection null, ip4Config null and empty addressData. Each asserts getWifiSubmask(), getWifiBroadcast() and getWifiIP() return null. All three fail without the fix.

Note for reviewers: @TestOn('linux') was dropped from network_info_plus_linux_test.dart since the tests use fakes and run on any host. #3942 makes the same change to this file with the same fake-class style, so whichever merges second will have a trivial conflict (keep both test groups and share the fakes).

Related Issues

Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I titled the PR using Conventional Commits.
  • I did not modify the CHANGELOG.md nor the plugin version in pubspec.yaml files.
  • All existing and new tests are passing.
  • The analyzer (flutter analyze) does not report any problems on my PR.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate that with a ! in the title as explained in Conventional Commits).
  • No, this is not a breaking change.

🤖 Generated with Claude Code

vbuberen and others added 2 commits September 28, 2026 14:32
…st when IPv4 data is missing

`_getSubnetMask` cast a missing prefix to `int`, throwing a TypeError when
there was no primary connection, no ip4Config or empty addressData.
`_getBroadcast` now also returns null instead of computing a bogus value
from zero fallbacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st when IPv4 data is missing

`_getSubnetMask` cast a missing prefix to `int`, throwing a TypeError when
there was no primary connection, no ip4Config or empty addressData.
`_getBroadcast` now also returns null instead of computing a bogus value
from zero fallbacks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vbuberen
vbuberen force-pushed the network_info_plus_linux_null_subnet branch from 8b5f34f to 951d027 Compare September 28, 2026 12:32
vbuberen and others added 3 commits September 29, 2026 13:24
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…or on Windows example

Newer MSVC in the windows-latest image turns STL1011 into a hard error,
which breaks permission_handler_windows.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@vbuberen
vbuberen merged commit 2df7ac5 into main Sep 29, 2026
18 of 21 checks passed
@vbuberen
vbuberen deleted the network_info_plus_linux_null_subnet branch September 29, 2026 11:10
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.

1 participant