I have a DraggableScrollableSheet
with FlutterMap
. I want that the Map widget adjusts its height to the remaining height of the draggable sheet.
Here is my widget tree
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Row(children: [
CommonWidgets.createRouteBadge(route, routeTypes?[route?.type]?.name,
Theme.of(context).primaryColor, 18),
const SizedBox(
width: 10,
),
Expanded(
child: Text(
CommonWidgets.formatTripHeadsign(trip!.tripHeadsign),
softWrap: true,
))
]),
actions: (widget.stopId != null) ? [IconButton(
onPressed: () {
showStopRouteTimetable(route!.id!, widget.stopId!);
},
icon: const Icon(Icons.calendar_month),
color: Theme.of(context).primaryColor,
)] : [],
),
body: Stack(
children: [
OsmMapWidget<StopWithStopTime>(
useMarkerClustering: false,
showCurrentLocation: true,
initialZoom: 15,
getTripStopMarkers(),
getTripShape()?.let((that) => [that]) ?? getTripShapeFromStopPoints() ?.let((that) => [that]) ?? [],
(stop) {
return InkWell(child: createTripStopWidget(stop.stop), onTap: () {
selectStop(stop.stop.id);
mapController?.center(Location(stop.stop.lat!, stop.stop.lon!), null, null);
},);
},
(mapController) {
this.mapController = mapController;
},
),
Visibility(
visible: isLoading,
child: const LinearProgressIndicator(
value: null,
),
),
DraggableScrollableSheet(
controller: sheetController,
maxChildSize: 0.5,
minChildSize: 0.2,
expand: true,
shouldCloseOnMinExtent: true,
snap: true,
builder: (BuildContext context, scrollController) {
return Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: Theme.of(context).canvasColor,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(25),
topRight: Radius.circular(25),
),
),
child: CustomScrollView(
controller: scrollController,
slivers: [
SliverToBoxAdapter(
child: Center(
child: Container(
decoration: BoxDecoration(
color: Theme.of(context).hintColor,
borderRadius: const BorderRadius.all(Radius.circular(10)),
),
height: 4,
width: 40,
margin: const EdgeInsets.symmetric(vertical: 10),
),
),
),
stopTimes?.isNotEmpty == true ?
SliverList.builder(
itemCount: stopTimes?.length ?? 0,
itemBuilder: (context, index) {
final stopTimeUpdate = stopTimes?[index];
final stop = allStops?[stopTimeUpdate?.stopId];
final isSelected = selectedStopId == stop?.id;
final isVehicleThere = false;//tripUpdate?.
return TripStopItem(
index: index,
totalCount: stopTimes?.length ?? 0,
stop: stop!,
stopTimeUpdate: stopTimeUpdate!,
isSelected: isSelected,
isVehicleThere: isVehicleThere,
itemClickListener: (stopTime, stop) {
selectStop(stop.id);
mapController?.center(Location(stop.lat!, stop.lon!), null, null);
},);
},
) : SliverToBoxAdapter(
child: Container(
alignment: AlignmentDirectional.center,
child: CommonWidgets.createEmptyState(
isLoading ? AppLocalizations.of(context)!.loading : AppLocalizations.of(context)!.no_departures,
Icons.directions_bus, isLoading)))
],
),
);
},
),
],
),
);
}