I need to add a GoogleMap view inside a ListView and want it to get the full available space on screen (without scroll)
How can I do that ?
But always receive the error about infinity height ):
This is what I tried:
Scaffold(
appBar: const CustomAppBar(),
body: NestedScrollView(
physics: const ClampingScrollPhysics()(),
headerSliverBuilder: (context, innerBoxIsScrolled) => [
SliverAppBar(
floating: false,
pinned: true,
expandedHeight: 80,
collapsedHeight: 56,
backgroundColor: AppColors.black,
flexibleSpace: const FlexibleTitleAppBar(),
),
],
body: ListView(
shrinkWrap: true,
physics: const ClampingScrollPhysics(),
children: [
Container(
color: AppColors.black,
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16, top: 28, bottom: 28),
child: HeaderComponent(),
)
),
Expanded(
flex: 1
child: GoogleMaps(
compassEnabled: false,
initialCameraPosition: cameraPosition,
gestureRecognizers: Set()
..add(
Factory<EagerGestureRecognizer>(
() => EagerGestureRecognizer(),
),
),
markers: markers,
);
),
],
),
),
);
2
Answers
Maybe you can try wrap the listview widget with SizedBox. And then give the
SizedBox’s height-width value using MediaQuery or just static number.
I have modified your Scaffold variables to run at my end. Make the necessary changes your end. Here’s the solution. Try with this. I have replaced ListView with Column.