Skip to content

[google_maps_flutter_platform_interface] Add editable polyline and polygon API#11492

Open
lume-code wants to merge 1 commit into
flutter:mainfrom
lume-code:editable-shapes
Open

[google_maps_flutter_platform_interface] Add editable polyline and polygon API#11492
lume-code wants to merge 1 commit into
flutter:mainfrom
lume-code:editable-shapes

Conversation

@lume-code

@lume-code lume-code commented Apr 12, 2026

Copy link
Copy Markdown

Updated: Per review feedback, this PR has been split along the federated plugin so the platform interface lands first (contributing guidelines). This PR is now scoped to the platform interface only. The implementation follows in:

Adds the platform-interface API surface for editable polylines and polygons. This has been requested since November 2020 (flutter/flutter#71248).

Changes — google_maps_flutter_platform_interface (2.15.0 → 2.16.0)

  • Adds editable (bool, default false) and onEdited (callback) fields to Polyline and Polygon.
  • Adds PolylineEditEvent and PolygonEditEvent map event types.
  • Adds onPolylineEdited and onPolygonEdited streams to GoogleMapsFlutterPlatform (default UnimplementedError).

All additions are non-breaking: the new constructor parameters are defaulted/optional, and the new platform methods have default implementations.

Editing is implemented for web only (see #11919); the property is silently ignored on Android and iOS.

Fixes flutter/flutter#71248

Pre-Review Checklist

Footnotes

  1. See the test exemption and version/CHANGELOG exemption docs for details. 2

@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@google-cla

google-cla Bot commented Apr 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for user-editable Polygons and Polylines on the web platform by adding an editable property and an onEdited callback to the respective classes. The implementation includes new event types in the platform interface and logic in the web plugin to listen for path changes via the Google Maps JavaScript API. Review feedback highlights that the current Polygon implementation fails to include hole data in the edit events and callbacks. Furthermore, the web controllers only set up edit listeners during construction, which prevents the functionality from working if the editable property is enabled after the object is created.

Comment thread packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygon.dart Outdated
Comment thread packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygon.dart Outdated
Comment thread packages/google_maps_flutter/google_maps_flutter_web/lib/src/polyline.dart Outdated
@lume-code lume-code changed the title feat(google_maps_flutter): add editable polyline and polygon support [google_maps_flutter] Add editable polyline and polygon support (web) Apr 12, 2026
@lume-code lume-code force-pushed the editable-shapes branch 2 times, most recently from d90a83b to 00e1ec3 Compare April 12, 2026 06:27
@stuartmorgan-g stuartmorgan-g added the triage-web Should be looked at in web triage label Apr 14, 2026
@stuartmorgan-g stuartmorgan-g requested a review from mdebbar April 14, 2026 18:35
@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

20 in platform_interface, 4 in main package

This PR has substantive changes to three packages; so can't have comprehensive test coverage without adding tests in all three.

@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

From triage: @lume-code Are you planning on adding the necessary test coverage for this to move forward?

@mdebbar

mdebbar commented May 13, 2026

Copy link
Copy Markdown
Contributor

From web triage: @lume-code are you still planning to move forward with this PR?

@lume-code

lume-code commented May 15, 2026

Copy link
Copy Markdown
Author

@mdebbar yes, still moving forward — sorry for the delay. Web test coverage is now in (commit 81bf57a), and the branch has been rebased onto current main.

The new tests live under packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/ and add 18 cases across shape_test.dart (controller-level) and shapes_test.dart (controllers + stream-level). They cover:

  • editable is forwarded to the underlying gmaps.Polyline / gmaps.Polygon option
  • onEdited fires on MVCArray setAt / insertAt / removeAt for both controllers
  • PolygonEditEvent.holes is populated, and edits to a hole path also fire the event (regression for the missing-holes review comment)
  • No event is emitted when the shape is not editable
  • changePolylines / changePolygons rewires the edit listeners when editable is toggled false → true (regression for the "listener not re-subscribed on update" review comment)
  • remove() cancels the edit subscriptions

All tests pass locally. Ready for another look whenever you have a moment.

@mdebbar mdebbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes look good to me!

I think this PR now needs to be split so the platform interface package lands first?

…n API

Adds the platform-interface surface for editable polylines and polygons:
- `editable` property and `onEdited` callback on `Polyline` and `Polygon`.
- `PolylineEditEvent` and `PolygonEditEvent` map event types.
- `onPolylineEdited` / `onPolygonEdited` streams on the platform interface
  (default `UnimplementedError`, so the addition is non-breaking).

Bumps to 2.16.0. First of three PRs splitting flutter#11492 along the
federated plugin (interface lands and publishes first).
@lume-code lume-code changed the title [google_maps_flutter] Add editable polyline and polygon support (web) [google_maps_flutter_platform_interface] Add editable polyline and polygon API Jun 17, 2026
@lume-code

lume-code commented Jun 17, 2026

Copy link
Copy Markdown
Author

Thanks for the review! As suggested, I've split this along the federated plugin so the platform interface can land and publish first.

This PR (#11492) is now scoped to google_maps_flutter_platform_interface only. The follow-ups, stacked in dependency order, are open as drafts and will be ready once the package(s) they depend on publish:

  1. [google_maps_flutter_platform_interface] Add editable polyline and polygon API #11492google_maps_flutter_platform_interface (2.16.0) ← lands & publishes first
  2. [google_maps_flutter_web] Add editable polyline and polygon support #11919google_maps_flutter_web (0.7.0) — depends on the published interface
  3. [google_maps_flutter] Add editable polyline and polygon support (web) #11920google_maps_flutter (2.18.0) — depends on the published interface + web

lume-code added a commit to lume-code/packages that referenced this pull request Jun 17, 2026
Implements editable polylines and polygons on web using the Google Maps
JavaScript API `editable` flag:
- Wires `editable`/`onEdited` through to the JS `Polyline`/`Polygon` controllers.
- Listens to MVCArray path-change events and emits `PolylineEditEvent` /
  `PolygonEditEvent` (including polygon holes).
- Recreates the controller on change so edit listeners rewire when `editable` toggles.

Bumps to 0.7.0. Second of three PRs splitting flutter#11492; depends on
google_maps_flutter_platform_interface 2.16.0.
lume-code added a commit to lume-code/packages that referenced this pull request Jun 17, 2026
Subscribes to the platform interface `onPolylineEdited` / `onPolygonEdited`
streams and dispatches them to the `onEdited` callbacks on `Polyline` / `Polygon`.
Editing is currently only supported on web.

Bumps to 2.18.0. Third of three PRs splitting flutter#11492; depends on
google_maps_flutter_platform_interface 2.16.0 and google_maps_flutter_web 0.7.0.
lume-code added a commit to lume-code/packages that referenced this pull request Jun 18, 2026
Implements editable polylines and polygons on web using the Google Maps
JavaScript API `editable` flag:
- Wires `editable`/`onEdited` through to the JS `Polyline`/`Polygon` controllers.
- Listens to MVCArray path-change events and emits `PolylineEditEvent` /
  `PolygonEditEvent` (including polygon holes).
- Recreates the controller on change so edit listeners rewire when `editable` toggles.

Bumps to 0.7.0. Second of three PRs splitting flutter#11492; depends on
google_maps_flutter_platform_interface 2.16.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: google_maps_flutter triage-web Should be looked at in web triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[google_maps_flutter_web] Add "User-Editable Shapes" feature

3 participants