我在单个子滚动视图中的应用程序中使用谷歌地图插件以及一些列表和其他小部件。问题是当我向下或向上滚动时,谷歌地图小部件粘在顶部或底部与其他小部件重叠,如下所示。我试图通过 github 和 stackoverflow 上的现有问题,但找不到任何解决方案。如果有人遇到同样的问题或有解决方案,请帮助我。
问题-> https://gifyu.com/image/YVZx
这是重现相同问题的代码。
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Completer<GoogleMapController> _controller = Completer();
static final CameraPosition _kGooglePlex = CameraPosition(
target: LatLng(37.42796133580664, -122.085749655962),
zoom: 14.4746,
);
static final CameraPosition _kLake = CameraPosition(
bearing: 192.8334901395799,
target: LatLng(37.43296265331129, -122.08832357078792),
tilt: 59.440717697143555,
zoom: 19.151926040649414);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('iOS Map'),
),
body: SingleChildScrollView(
child: Column(
children: [
ListView.builder(
itemCount: 20,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (ctx, index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
child: Text('Test item $index'),
),
);
}),
SizedBox(
height: 250,
child: GoogleMap(
mapType: MapType.hybrid,
initialCameraPosition: _kGooglePlex,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
),
),
ListView.builder(
itemCount: 50,
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
itemBuilder: (ctx, index) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Card(
child: Text('Test item $index'),
),
);
}),
],
),
),
);
}
}