使用BitmapDescriptor添加自定义标记会引发“无法解码图像。提供的图像必须是位图。”错误

时间:2019-07-18 19:49:13

标签: google-maps flutter marker

我正在尝试在地图中添加自定义标记。

class Foo{
  BitmapDescriptor myIcon;
  Foo(){
  BitmapDescriptor.fromAssetImage(
        ImageConfiguration(size: Size(38, 38)), 'assets/marker.png')
        .then((onValue) {
      myIcon = onValue;
    });
  }
  Marker getMarker(){
    return Marker(markerId: MarkerId("123"),
             icon: myIcon,
  }
}

在pubspec.yaml中

    assets:
        - assets/marker.png

抛出以下错误:

E/MethodChannel#plugins.flutter.io/google_maps_0( 7524): Failed to handle method call
E/MethodChannel#plugins.flutter.io/google_maps_0( 7524): com.google.maps.api.android.lib6.common.apiexception.c: Failed to decode image. The provided image must be a Bitmap.

0 个答案:

没有答案