如何在Google Map Flutter上显示小部件图标?

时间:2019-09-17 05:59:40

标签: google-maps flutter dart google-maps-flutter

在我的应用程序中有一张Google地图。我使用了google_maps_flutter。我想在右上角添加通知图标。我尝试使用Stack,但Google Map覆盖了图标。

This is what I want

This is I achived after comment google map code

This is my current screen with below code

代码

Scaffold(
  resizeToAvoidBottomInset: true,
  body: Stack(
    children: <Widget>[
      Positioned(
          top: 60,
          right: 40,
          child: IconButton(
            icon: new Image.asset(UIData.notificationIcon),
            onPressed: () {},
          )),
      GoogleMap(
          myLocationEnabled: true,
          myLocationButtonEnabled: true,
          mapType: MapType.normal,
          initialCameraPosition: _kGooglePlex,
          markers: Set<Marker>.of(markers.values),
          onMapCreated: (controller) {
            if (this.mounted)
              setState(() {
                myController = controller;
              });
          })
    ],
  ),
);

1 个答案:

答案 0 :(得分:0)

只需在Google地图下方移动响铃图标,请尝试替换以下代码,即可在我这方面正常工作

enter image description here

Scaffold(
  resizeToAvoidBottomInset: true,
  body: Stack(
children: <Widget>[
  GoogleMap(
      myLocationEnabled: true,
      myLocationButtonEnabled: true,
      mapType: MapType.normal,
      initialCameraPosition: _kGooglePlex,
      markers: Set<Marker>.of(markers.values),
      onMapCreated: (controller) {
        if (this.mounted)
          setState(() {
            myController = controller;
          });
      }),
  Positioned(
      top: 60,
      right: 40,
      child: IconButton(
        icon: new Image.asset(UIData.notificationIcon),
        onPressed: () {},
      )),
    ],
  ),
);