From fabb01d776bf29496f01d46860a433a8a56841d3 Mon Sep 17 00:00:00 2001 From: Tim Sneath Date: Thu, 2 Jan 2020 17:40:20 -0800 Subject: [PATCH 1/3] uncomment set marker icon sample --- .../example/lib/place_marker.dart | 92 ++++++++----------- 1 file changed, 40 insertions(+), 52 deletions(-) diff --git a/packages/google_maps_flutter/example/lib/place_marker.dart b/packages/google_maps_flutter/example/lib/place_marker.dart index ce0f9d436699..88438d041b53 100644 --- a/packages/google_maps_flutter/example/lib/place_marker.dart +++ b/packages/google_maps_flutter/example/lib/place_marker.dart @@ -244,42 +244,36 @@ class PlaceMarkerBodyState extends State { }); } -// A breaking change to the ImageStreamListener API affects this sample. -// I've updates the sample to use the new API, but as we cannot use the new -// API before it makes it to stable I'm commenting out this sample for now -// TODO(amirh): uncomment this one the ImageStream API change makes it to stable. -// https://github.com/flutter/flutter/issues/33438 -// -// void _setMarkerIcon(BitmapDescriptor assetIcon) { -// if (selectedMarker == null) { -// return; -// } -// -// final Marker marker = markers[selectedMarker]; -// setState(() { -// markers[selectedMarker] = marker.copyWith( -// iconParam: assetIcon, -// ); -// }); -// } -// -// Future _getAssetIcon(BuildContext context) async { -// final Completer bitmapIcon = -// Completer(); -// final ImageConfiguration config = createLocalImageConfiguration(context); -// -// const AssetImage('assets/red_square.png') -// .resolve(config) -// .addListener(ImageStreamListener((ImageInfo image, bool sync) async { -// final ByteData bytes = -// await image.image.toByteData(format: ImageByteFormat.png); -// final BitmapDescriptor bitmap = -// BitmapDescriptor.fromBytes(bytes.buffer.asUint8List()); -// bitmapIcon.complete(bitmap); -// })); -// -// return await bitmapIcon.future; -// } + void _setMarkerIcon(BitmapDescriptor assetIcon) { + if (selectedMarker == null) { + return; + } + + final Marker marker = markers[selectedMarker]; + setState(() { + markers[selectedMarker] = marker.copyWith( + iconParam: assetIcon, + ); + }); + } + + Future _getAssetIcon(BuildContext context) async { + final Completer bitmapIcon = + Completer(); + final ImageConfiguration config = createLocalImageConfiguration(context); + + const AssetImage('assets/red_square.png') + .resolve(config) + .addListener(ImageStreamListener((ImageInfo image, bool sync) async { + final ByteData bytes = + await image.image.toByteData(format: ImageByteFormat.png); + final BitmapDescriptor bitmap = + BitmapDescriptor.fromBytes(bytes.buffer.asUint8List()); + bitmapIcon.complete(bitmap); + })); + + return await bitmapIcon.future; + } @override Widget build(BuildContext context) { @@ -365,22 +359,16 @@ class PlaceMarkerBodyState extends State { child: const Text('change zIndex'), onPressed: _changeZIndex, ), - // A breaking change to the ImageStreamListener API affects this sample. - // I've updates the sample to use the new API, but as we cannot use the new - // API before it makes it to stable I'm commenting out this sample for now - // TODO(amirh): uncomment this one the ImageStream API change makes it to stable. - // https://github.com/flutter/flutter/issues/33438 - // - // FlatButton( - // child: const Text('set marker icon'), - // onPressed: () { - // _getAssetIcon(context).then( - // (BitmapDescriptor icon) { - // _setMarkerIcon(icon); - // }, - // ); - // }, - // ), + FlatButton( + child: const Text('set marker icon'), + onPressed: () { + _getAssetIcon(context).then( + (BitmapDescriptor icon) { + _setMarkerIcon(icon); + }, + ); + }, + ), ], ), ], From 6b34432c59d0035615da3408f0298968642b388a Mon Sep 17 00:00:00 2001 From: Tim Sneath Date: Thu, 2 Jan 2020 17:40:36 -0800 Subject: [PATCH 2/3] Add typed_data import --- packages/google_maps_flutter/example/lib/place_marker.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/google_maps_flutter/example/lib/place_marker.dart b/packages/google_maps_flutter/example/lib/place_marker.dart index 88438d041b53..161a553d0930 100644 --- a/packages/google_maps_flutter/example/lib/place_marker.dart +++ b/packages/google_maps_flutter/example/lib/place_marker.dart @@ -7,6 +7,7 @@ import 'dart:async'; import 'dart:math'; import 'dart:ui'; +import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; From 002732dd699a4ed42d45d2cb9c2e2688b312e4aa Mon Sep 17 00:00:00 2001 From: Tim Sneath Date: Thu, 2 Jan 2020 17:40:46 -0800 Subject: [PATCH 3/3] Update CHANGELOG and pubspec version --- packages/google_maps_flutter/CHANGELOG.md | 5 +++++ packages/google_maps_flutter/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/CHANGELOG.md index 0f6908eb130b..46138478b561 100644 --- a/packages/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.5.21+16 + +* Uncomment the marker icon example. + See: https://github.com/flutter/flutter/issues/33438 + ## 0.5.21+15 * Remove the deprecated `author:` field from pubspec.yaml diff --git a/packages/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/pubspec.yaml index f29c41cf221f..a56c253e984f 100644 --- a/packages/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/pubspec.yaml @@ -1,7 +1,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. homepage: https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter -version: 0.5.21+15 +version: 0.5.21+16 dependencies: flutter: