Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/google_maps_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
93 changes: 41 additions & 52 deletions packages/google_maps_flutter/example/lib/place_marker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -244,42 +245,36 @@ class PlaceMarkerBodyState extends State<PlaceMarkerBody> {
});
}

// 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<BitmapDescriptor> _getAssetIcon(BuildContext context) async {
// final Completer<BitmapDescriptor> bitmapIcon =
// Completer<BitmapDescriptor>();
// 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<BitmapDescriptor> _getAssetIcon(BuildContext context) async {
final Completer<BitmapDescriptor> bitmapIcon =
Completer<BitmapDescriptor>();
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) {
Expand Down Expand Up @@ -365,22 +360,16 @@ class PlaceMarkerBodyState extends State<PlaceMarkerBody> {
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);
},
);
},
),
],
),
],
Expand Down
2 changes: 1 addition & 1 deletion packages/google_maps_flutter/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down