Skip to content

[google_maps_flutter] Refactor Map widget creationParams #70330

@ditman

Description

@ditman

The current version of the buildView method in Google Maps' platform interface is completely oriented towards the Method Channel implementation (there are other examples, but this is the worst offender).

The core plugin eagerly transforms everything into a JSON-ifiable object (Map<String, dynamic>) here:

https://github.com/flutter/plugins/blob/0d5dd3a2d93ec545653ee26a3c59b72459fb51ac/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart#L227-L235

This causes problems in the web implementation, that normally needs one extra step to undo that transformation so it can operate with less stringly typed data structures.

Another problem of this, is that Controller methods operate with the normal data structures until it's strictly necessary to convert them, so any fixes in Web need to verify the "initial geometry case" (handling the early serialization), and the "controller injected changes" (which don't serialize and handle the proper data structures).

Proposal

  1. Introduce a new buildView platform method that uses semantic parameters and proper types (the same as the Controller methods)
  2. Keep the supplied types for as long as possible, and convert those ".toJson" only when doing a MethodChannel call.
  3. Remove all the code required to handle the early serialization from the interface and the web implementation.

This would allow web to remove a good chunk of this file, which deals with converting rawOptions to proper types again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: tech-debtTechnical debt, code quality, testing, etc.p: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.platform-webWeb applications specifically

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions