Skip to content

feat(flet-map): add Map.get_camera(), MapEventType, and enhance MapEvent payload#6208

Open
ndonkoHenri wants to merge 14 commits intomainfrom
improve-map
Open

feat(flet-map): add Map.get_camera(), MapEventType, and enhance MapEvent payload#6208
ndonkoHenri wants to merge 14 commits intomainfrom
improve-map

Conversation

@ndonkoHenri
Copy link
Contributor

@ndonkoHenri ndonkoHenri commented Feb 24, 2026

Fix #6196

Summary by Sourcery

Extend flet-map with richer map events and camera inspection while updating docs and examples to showcase new capabilities.

New Features:

  • Expose Map.get_camera() to retrieve the current camera state from Python.
  • Introduce MapEventType enum and MapEvent.event_type to describe concrete map event kinds.
  • Augment MapEvent payloads with optional old_camera, coordinates, and id fields for more detailed interaction context.
  • Add new map examples for basic usage, camera controls, interaction flags, idle camera detection, and multi-layer maps.

Bug Fixes:

  • Correct the MapEventSource.INTERACTIVE_FLAGS_CHANGED value to match the underlying Flutter map event source string.

Enhancements:

  • Standardize enum parsing utilities on a shared parseEnum helper in Flutter utilities.
  • Switch map event handler enablement from boolean properties to presence-based event handler checks.
  • Enrich Map.on_position_change documentation to clarify when it fires.
  • Adjust Flutter map control method invocation to safely handle null args when calling platform methods.

Documentation:

  • Reorganize and expand map documentation with multiple categorized examples and a new MapEventType type reference page.
  • Tidy the platform support table formatting in map documentation.

@ndonkoHenri ndonkoHenri requested a review from Copilot February 24, 2026 02:43
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@ndonkoHenri ndonkoHenri changed the title feat(flet-map): add Map.get_camera(), MapEventType, and enhanced MapEvent payload feat(flet-map): add Map.get_camera(), MapEventType, and enhance MapEvent payload Feb 24, 2026
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 24, 2026

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: f92a359
Status: ✅  Deploy successful!
Preview URL: https://d131e37a.flet-docs.pages.dev
Branch Preview URL: https://improve-map.flet-docs.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 24, 2026

Deploying flet-examples with  Cloudflare Pages  Cloudflare Pages

Latest commit: f92a359
Status: ✅  Deploy successful!
Preview URL: https://8b7d7d7f.flet-examples.pages.dev
Branch Preview URL: https://improve-map.flet-examples.pages.dev

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds new camera-query and richer event typing to the flet-map Python/Flutter integration to address frequent on_position_change updates by allowing consumers to query a stable camera snapshot and classify map events.

Changes:

  • Added Map.get_camera() method (Flutter invoke + Python API) to retrieve the current camera snapshot on demand.
  • Introduced MapEventType and expanded MapEvent payload with event_type, old_camera, coordinates, and id.
  • Updated docs navigation and Map docs page, plus added multiple new/updated Python examples.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sdk/python/packages/flet/mkdocs.yml Adds MapEventType to generated docs navigation.
sdk/python/packages/flet/docs/map/types/mapeventtype.md New docs stub to render MapEventType API reference.
sdk/python/packages/flet/docs/map/index.md Expands Map docs with multiple example snippets.
sdk/python/packages/flet-map/src/flutter/flet_map/lib/src/utils/map.dart Refactors enum parsing, switches event wiring to hasEventHandler, and enriches MapEvent serialization payload.
sdk/python/packages/flet-map/src/flutter/flet_map/lib/src/utils/attribution_alignment.dart Refactors enum parsing to shared parseEnum.
sdk/python/packages/flet-map/src/flutter/flet_map/lib/src/map.dart Adds "get_camera" invoke-method and normalizes null args handling.
sdk/python/packages/flet-map/src/flet_map/types.py Adds MapEventType, expands MapEvent, and fixes MapEventSource.INTERACTIVE_FLAGS_CHANGED value.
sdk/python/packages/flet-map/src/flet_map/map.py Adds Map.get_camera() Python API and updates some docstrings.
sdk/python/packages/flet-map/src/flet_map/init.py Re-exports MapEventType.
sdk/python/packages/flet-map/CHANGELOG.md Documents new API additions and the event-source fix.
sdk/python/examples/controls/map/multi_layers.py Updates example to use layer variables (walrus assignment) instead of Ref.
sdk/python/examples/controls/map/interaction_flags.py New example showing interaction flag toggling and event introspection.
sdk/python/examples/controls/map/idle_camera.py New example demonstrating “camera idle” pattern using MapEventType + get_camera().
sdk/python/examples/controls/map/camera_controls.py New example for imperative camera control methods + get_camera().
sdk/python/examples/controls/map/basic.py New minimal map example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ndonkoHenri ndonkoHenri linked an issue Feb 24, 2026 that may be closed by this pull request
1 task
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.

Troubleshooting Prerelease compatibility issues Map: add stable camera APIs and richer event metadata

2 participants