Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrates geolocator_web to package:web #1475

Merged
merged 7 commits into from
May 16, 2024

Conversation

josh-burton
Copy link
Contributor

@josh-burton josh-burton commented Apr 2, 2024

This PR migrates from dart:html to package:web and js_interop.

A few notes/questions:

  • I've increased the dart/flutter sdk versions in geolocator_web in order to use js_interop. I'm unsure if we need to bump these versions in the other geolocator packages as well.
  • Mockito can no longer be used with the new js_interop types (at least I ran into errors with it being unable to generate mocks).
  • The package:web geolocation methods now require a timeout value, rather than allowing null. Infinity is the value for timeouts in the html geolocation api, but passing double.infinity.toInt as timeout throws an error that this is an invalid value when invoked in javascript. Instead of defaulted to a timeout of 1 day, but this needs more input.
  • the test now require running with flutter test --platform chrome, otherwise errors are thrown as js_interop can't be used in the dart vm.

Pre-launch Checklist

  • I made sure the project builds.
  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is does not need version changes.
  • I updated CHANGELOG.md to add a description of the change.
  • I updated/added relevant documentation (doc comments with ///).
  • I rebased onto main.
  • I added new tests to check the change I am making, or this PR does not need tests.
  • I made sure all existing and new tests are passing.
  • I ran dart format . and committed any changes.
  • I ran flutter analyze and fixed any errors.

Copy link
Member

@mvanbeusekom mvanbeusekom left a comment

Choose a reason for hiding this comment

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

Hi @josh-burton,

Sorry for the delay and thank you for creating this PR. In general the changes look good, I have made a few small remarks which would be great if you can address those.

geolocator_web/lib/src/html_permissions_manager.dart Outdated Show resolved Hide resolved
geolocator_web/CHANGELOG.md Outdated Show resolved Hide resolved
} on html.PositionError catch (e) {
throw convertPositionError(e);
} catch (e) {
completer.completeError(e);
Copy link
Member

Choose a reason for hiding this comment

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

Please convert the error to one of the custom exceptions defined in the convertPositionError method before completing the completer.

This will throw a known exception to the application developers so they don't have to update their application logic and handle unexpected exceptions solely for the geolocator_web plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've returned a platform exception so the caught exception can be passed to the detail field. Another option could be the PositionUpdateException exception

Copy link
Member

Choose a reason for hiding this comment

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

I think the PositionUpdateException would be an excellent fit here. Using the PlatformException causes developers to worry about the LOCATION_UPDATE_FAILURE error code while their code base should already be handling the PositionUpdateException (if written correctly of course).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, my only concern there is the underlying exception will be lost. Perhaps we could add an optional cause field to the PositionUpdateException?

@josh-burton
Copy link
Contributor Author

Hi @josh-burton,

Sorry for the delay and thank you for creating this PR. In general the changes look good, I have made a few small remarks which would be great if you can address those.

Thanks for the review. I believe I've addressed them now.

@mvanbeusekom
Copy link
Member

When merged solves #1513

@josh-burton
Copy link
Contributor Author

@mvanbeusekom I see the workflows are failing. I had bumped the geolocator_web version to 4.0 as its a breaking change, but as 4.0 is not published the workflows now error.

What's the correct fix here?

@mvanbeusekom
Copy link
Member

The best would be to split the changes into 2 PRs. One updating the geolocator_web package and a second bumping the version for the geolocator package.

  • However in this case the change in the geolocator package is so small that I don't mind the failing build. As long as the steps for the geolocator_web are green.

Copy link
Member

@mvanbeusekom mvanbeusekom left a comment

Choose a reason for hiding this comment

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

LGTM

@mvanbeusekom mvanbeusekom merged commit 93a9289 into Baseflow:main May 16, 2024
0 of 2 checks passed
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.

None yet

2 participants