Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[connectivity_for_web] Migration to null-safety. #3652

Merged
merged 7 commits into from
Mar 2, 2021

Conversation

ditman
Copy link
Member

@ditman ditman commented Mar 2, 2021

This change migrates the package to null safety, and moves its (very obsolete) tests to the new integration_test style.

The tests used to use mockito, but those mocks have been replaced by Fake implementations.

Tests

  • Tested manually with the connectivity/example app, in Sound null-safe mode.
  • Tests still pass with minimal changes (rewritten Mockito mocks as Fakes)

Pre-launch Checklist

  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test exempt.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@@ -18,7 +18,7 @@ class NetworkInformationApiConnectivityPlugin extends ConnectivityPlugin {

/// The constructor of the plugin.
NetworkInformationApiConnectivityPlugin()
: this.withConnection(html.window.navigator.connection);
: this.withConnection(html.window.navigator.connection!);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is ensured by the isSupported method that is used before instantiating this plugin class.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems worth documenting that requirement in the constructor comment.

Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

LGTM with nits

? ConnectivityResult.wifi
: ConnectivityResult.none;
}

StreamController<ConnectivityResult> _connectivityResult;
late StreamController<ConnectivityResult> _connectivityResult;
Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, I thought you couldn't null-check a late value (and that lazy initialization like the below needed ? as a result).

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, let me give this a test!

Copy link
Member Author

Choose a reason for hiding this comment

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

This was indeed crashy. Fixed. This file needs a test (mock window + navigator), I'll add one after this lands.

@@ -18,7 +18,7 @@ class NetworkInformationApiConnectivityPlugin extends ConnectivityPlugin {

/// The constructor of the plugin.
NetworkInformationApiConnectivityPlugin()
: this.withConnection(html.window.navigator.connection);
: this.withConnection(html.window.navigator.connection!);
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems worth documenting that requirement in the constructor comment.

@ditman
Copy link
Member Author

ditman commented Mar 2, 2021

The requirement of the 'connection' API is documented in the README: https://github.com/flutter/plugins/tree/master/packages/connectivity/connectivity_for_web#limitations-on-the-web-platform

@ditman ditman added the waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land. label Mar 2, 2021
@fluttergithubbot fluttergithubbot merged commit 72feefd into flutter:master Mar 2, 2021
@ditman ditman deleted the nnbd-connectivity_for_web branch March 2, 2021 19:15
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2021
NickalasB added a commit to NickalasB/plugins that referenced this pull request Mar 3, 2021
* master:
  Adopt Xcode 12 for podspec lints (flutter#3653)
  Run static analyzer during xctest (flutter#3667)
  [google_maps_flutter_web] update min flutter sdk version to 1.20.0 (flutter#3662)
  [image_picker] Run CocoaPods iOS tests in RunnerUITests target (flutter#3663)
  [webview_flutter] Run CocoaPods iOS tests in RunnerUITests target (flutter#3664)
  [device_info] Enable NNBD for unit test (flutter#3658)
  remove unused plugin (flutter#3661)
  [android_intent] move unit test to nullsafety (flutter#3659)
  [url_launcher] Migrate unit tests to NNBD (flutter#3657)
  [share] Migrate unit tests to null-safety. (flutter#3660)
  [connectivity_for_web] Migration to null-safety. (flutter#3652)
  [camera] Stable release for null safety. (flutter#3641)
  [in_app_purchase] fix plugin version (flutter#3654)
  Move plugin tool tests over (flutter#3606)
  [in_app_purchase] migrate playing billing library to v3 (flutter#3636)
  Update plugin_platform_interface min version (flutter#3650)

# Conflicts:
#	packages/webview_flutter/CHANGELOG.md
#	packages/webview_flutter/example/ios/Runner.xcodeproj/project.pbxproj
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes p: connectivity platform-web waiting for tree to go green (Use "autosubmit") This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants