Skip to content

feat(wifi_iot): add connectWithResult with native error details - #439

Open
JarenFeng wants to merge 1 commit into
flutternetwork:masterfrom
JarenFeng:feat/connect-with-result
Open

JarenFeng wants to merge 1 commit into
flutternetwork:masterfrom
JarenFeng:feat/connect-with-result

Conversation

@JarenFeng

Copy link
Copy Markdown

The boolean connection result does not expose the reason for a failed connection. Add connectWithResult() returning a typed WiFiConnectResult with a stable error code and available native error/status details.

Existing connect() and findAndConnect() retain their Future<bool> signatures and boolean method-channel contracts. Android's existing invalid-BSSID and unsupported-WEP exceptions are preserved for those callers.

  • Return code, isSuccess, nullable nativeCode, nativeDomain and message through the Dart result type.
  • Preserve Android network-suggestion status integers and iOS NSError codes, domains and localized messages.
  • Report local connection failures and adapter/configuration errors using stable codes; catch native builder exceptions instead of leaving the connection future unresolved.
  • Validate UTF-8 SSID length, missing passwords and timeout values before the new method invokes native code.
  • Document that Android withInternet: true success means the suggestion was accepted, and that onUnavailable() cannot reliably distinguish authentication failure from user rejection or other failures.

Validation:

  • 13 Flutter regression tests passed, covering the new API, native details, validation, missing plugins and existing boolean/exception contracts.
  • 17 assertions against the compiled Android result adapter passed.
  • Android example debug APK and iOS simulator example built with Flutter 3.47.1 / Dart 3.13.1.
  • Swift implementation type-checked against the iOS simulator SDK with an iOS 13 deployment target.
  • flutter analyze --no-pub, Dart format checks and project Java/Swift formatting passed.
  • Both proposed PRs merge cleanly. The combined tree passed the 13 regression tests plus a WPA3 parameter interoperability test and an Android build.

Physical-device connection testing has not been performed during this preparation. This PR does not add a network handle or change the package version/release changelog.

Related: #427.

Expose connection outcomes through an additive WiFiConnectResult API with
stable codes and available native code, domain and message information.
Preserve connect and findAndConnect boolean signatures and legacy channel
behavior so existing clients remain compatible.

Add Android and iOS result adapters, validate new API arguments and cover
the method-channel contract with regression tests. Document platform limits
without exposing a network handle or changing package release metadata.

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.

1 participant