getMapBytesFromUrl static method

Future<Uint8List> getMapBytesFromUrl(
  1. String url
)

final bitmapDescriptor = BitmapDescriptor.fromBytes(await _getBytesFromUrl('https://example.com/your-marker-image.png'));

Implementation

static Future<Uint8List> getMapBytesFromUrl(String url) async {
  final response = await http.get(Uri.parse(url));
  final bytes = response.bodyBytes;
  final imageCodec = await ui.instantiateImageCodec(bytes, targetWidth: 150); // Resize the image
  final frame = await imageCodec.getNextFrame();
  final data = await frame.image.toByteData(format: ui.ImageByteFormat.png);
  return data!.buffer.asUint8List();
}