android 调整GoogleMap抖动的高度

hmae6n7t  于 2023-03-06  发布在  Android
关注(0)|答案(2)|浏览(131)

我如何调整谷歌Map的高度,以便看到页面的背景稍微.我一直在使用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();
            }
          });
        },
      ),
    );
  }
}

谷歌Map页面

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,
            ))

    );
  }
}
piok6c0g

piok6c0g1#

您可以将GoogleMap小部件 Package 到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,
            )))
yeotifhr

yeotifhr2#

你也可以用SizedBox() Package googleMap

body:SizedBox(
        height: 300,
        child : GoogleMap(
            onMapCreated:  _onMapCreated,
            markers: _markers,
            initialCameraPosition: CameraPosition(target: LatLng(39.9042, 116.4074),
              zoom: 15,
        )))

相关问题