[英]Adjust the height of Google Maps Flutter
How can I adjust the height of a Google Map in order to see the background of the page slightly.如何调整 Google Map 的高度以便稍微看到页面背景。 I've been using
curved_navigation_bar
It would be great if anybody could help me out, thank you so much in advance..我一直在使用
curved_navigation_bar
如果有人可以帮助我,那就太好了,非常感谢你提前..
Widget _content = Container();
Color color = Colors.deepPurple;
class HomePage extends State<MyHomePage>{
@override
Widget build(BuildContext context){
return Scaffold(
backgroundColor: color,
body: _content,
bottomNavigationBar: CurvedNavigationBar(
backgroundColor: color,
items: [
Icon(Icons.home),
Icon(Icons.dashboard),
Icon(Icons.settings)
],
onTap: (index){
setState(() {
if (index ==0){
_content = GoogleMapScreen();
}
else if (index ==1){
_content = GoogleMapScreen();
}
else{
_content = GoogleMapScreen();
}
});
},
),
);
}
}
class GoogleMapScreen extends StatefulWidget{
@override
_GoogleMapScreenState createState() => _GoogleMapScreenState();
}
class _GoogleMapScreenState extends State<GoogleMapScreen>{
Set<Marker> _markers = {};
void _onMapCreated(GoogleMapController controller) {
setState(() {
_markers.add(
Marker(markerId: MarkerId('id-1'),
position: LatLng(39.9042, 116.4074),
infoWindow: InfoWindow(
title: 'Sample Marker',
snippet: 'A secret Place',
)
),
);
});
}
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(
title: Text('API MAP'),
),
body: GoogleMap(
onMapCreated: _onMapCreated,
markers: _markers,
initialCameraPosition: CameraPosition(target: LatLng(39.9042, 116.4074),
zoom: 15,
))
);
}
}
You can wrap your GoogleMap widget into a Padding:您可以将 GoogleMap 小部件包装到 Padding 中:
body:Padding(
padding: EdgeInsets.only(bottom 16.0),
child : GoogleMap(
onMapCreated: _onMapCreated,
markers: _markers,
initialCameraPosition: CameraPosition(target: LatLng(39.9042, 116.4074),
zoom: 15,
)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.