我是在扑动开发。我想要一个简单的地图应用程序。有一些特征。其中之一是当我点击标记然后显示自定义窗口时再次点击标记然后隐藏自定义窗口
在这一刻。只显示自定义窗口,但不隐藏自定义窗口,当点击标记。
我的源代码详细信息如下:
import 'package:clippy_flutter/triangle.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:custom_info_window/custom_info_window.dart';
class CustomInfoWindowF extends StatefulWidget {
@override
_CustomInfoWindowExampleState createState() =>
_CustomInfoWindowExampleState();
}
class _CustomInfoWindowExampleState extends State<CustomInfoWindowF> {
CustomInfoWindowController _customInfoWindowController =
CustomInfoWindowController();
final LatLng _latLng = LatLng(28.7041, 77.1025);
final double _zoom = 15.0;
@override
void dispose() {
_customInfoWindowController.dispose();
super.dispose();
}
Set<Marker> _markers = {};
@override
Widget build(BuildContext context) {
_markers.add(
Marker(
markerId: MarkerId("marker_id"),
position: _latLng,
onTap: () {
_customInfoWindowController.addInfoWindow(
Column(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(4),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.account_circle,
color: Colors.white,
size: 30,
),
SizedBox(
width: 8.0,
),
Text(
"I am here",
style:
Theme.of(context).textTheme.headline6.copyWith(
color: Colors.white,
),
)
],
),
],
),
),
width: double.infinity,
height: double.infinity,
),
),
Triangle.isosceles(
edge: Edge.BOTTOM,
child: Container(
color: Colors.blue,
width: 20.0,
height: 10.0,
),
),
],
),
_latLng,
);
},
),
);
return Scaffold(
appBar: AppBar(
title: Text('Custom Info Window Example'),
backgroundColor: Colors.red,
),
body: Stack(
children: <Widget>[
GoogleMap(
onTap: (position) {
_customInfoWindowController.hideInfoWindow();
},
onCameraMove: (position) {
_customInfoWindowController.onCameraMove();
},
onMapCreated: (GoogleMapController controller) async {
_customInfoWindowController.googleMapController = controller;
},
markers: _markers,
initialCameraPosition: CameraPosition(
target: _latLng,
zoom: _zoom,
),
),
CustomInfoWindow(
controller: _customInfoWindowController,
height: 175,
width: 250,
offset: 50,
),
],
),
);
}
}
我pubspec。下面的Yaml依赖文件源代码
google_maps_flutter: ^2.0.6
custom_info_window: ^1.0.1
clippy_flutter: ^1.1.1
创建一个按钮在我的CustomInfoWindow然后onPress叫
_customInfoWindowController.hideInfoWindow();
它将被解决。由于