Skip to content

Commit

Permalink
[google_maps_flutter] Partial Android host API Pigeon conversion (flu…
Browse files Browse the repository at this point in the history
…tter#6967)

Converts the host API methods other than the various map-object-update methods to Pigeon, as a starting point for a Pigeon conversion. This introduces the Pigeon structure for the main APIs, without getting into complex object serialization. Future work includes:
- Converting the update methods.
- Converting the calls from native to Dart (Flutter API in Pigeon terms).

Also replaces the very minimal Dart unit tests with full tests of all the new methods.

Part of flutter#117907
  • Loading branch information
stuartmorgan authored Jun 21, 2024
1 parent 8966342 commit f116dd2
Show file tree
Hide file tree
Showing 12 changed files with 1,613 additions and 301 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.10.0

* Converts some platform calls to Pigeon.

## 2.9.1

* Converts inspector interface platform calls to Pigeon.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,15 @@ static Object latLngToJson(LatLng latLng) {

static Messages.PlatformLatLng latLngToPigeon(LatLng latLng) {
return new Messages.PlatformLatLng.Builder()
.setLat(latLng.latitude)
.setLng(latLng.longitude)
.setLatitude(latLng.latitude)
.setLongitude(latLng.longitude)
.build();
}

static LatLng latLngFromPigeon(Messages.PlatformLatLng latLng) {
return new LatLng(latLng.getLatitude(), latLng.getLongitude());
}

static Object clusterToJson(String clusterManagerId, Cluster<MarkerBuilder> cluster) {
int clusterSize = cluster.getSize();
LatLngBounds.Builder latLngBoundsBuilder = LatLngBounds.builder();
Expand Down Expand Up @@ -500,17 +504,12 @@ static LatLng toLatLng(Object o) {
return new LatLng(toDouble(data.get(0)), toDouble(data.get(1)));
}

static Point toPoint(Object o) {
Object x = toMap(o).get("x");
Object y = toMap(o).get("y");
return new Point((int) x, (int) y);
static Point pointFromPigeon(Messages.PlatformPoint point) {
return new Point(point.getX().intValue(), point.getY().intValue());
}

static Map<String, Integer> pointToJson(Point point) {
final Map<String, Integer> data = new HashMap<>(2);
data.put("x", point.x);
data.put("y", point.y);
return data;
static Messages.PlatformPoint pointToPigeon(Point point) {
return new Messages.PlatformPoint.Builder().setX((long) point.x).setY((long) point.y).build();
}

private static LatLngBounds toLatLngBounds(Object o) {
Expand Down
Loading

0 comments on commit f116dd2

Please sign in to comment.