如何将DraggableScrollableSheet与GoogleMap和Stack结合使用?

时间:2020-06-15 11:06:48

标签: flutter flutter-layout

我正在尝试使DraggableScrollableSheet出现在Stack中的GoogleMap上方,但是没有运气。有什么提示吗?

这就是我正在尝试的

    body: Stack(
      children: <Widget>[
        GoogleMap(
          initialCameraPosition: CameraPosition(
              target: LatLng(47.502941, 18.999161),
              zoom: 1),
          myLocationEnabled: true,
          zoomControlsEnabled: true,
        ),
              Positioned(
                bottom: 0,
                left: 0,
                right: 0,
                child: Container(
                  height: 400,
                  color: Colors.white,
                  child: DraggableScrollableSheet(
                    initialChildSize: 0.4,
                    minChildSize: 0.1,
                    maxChildSize: 1,
                    builder: (context, scrollController) {
                      return Column(
                        children: <Widget>[

                          ListView.builder(
                            //controller: myscrollController,
                            shrinkWrap: true,
                            itemCount: 25,
                            itemBuilder: (BuildContext context, int index) {
                              return ListTile(
                                  title: Text(
                                'Dish $index',
                                style: TextStyle(color: Colors.black54),
                              ));
                            },
                          ),
                        ],
                      );
                    },
                  ),
                ),
              );

1 个答案:

答案 0 :(得分:1)

尝试使用sliding_up_panel

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text("Google Map"),
    ),
    body: SlidingUpPanel(
      panel: Center(
        child: Text("This is the sliding Widget"),
      ),
      body: Center(
        child: GoogleMap(
      initialCameraPosition: CameraPosition(
          target: LatLng(47.502941, 18.999161),
          zoom: 1),
      myLocationEnabled: true,
      zoomControlsEnabled: true,
    ),
      ),
    ),
  );
}