@@ -22,6 +22,8 @@ class ShowBottomSheetAction extends EnsembleAction {
2222 });
2323
2424 static const defaultTopBorderRadius = Radius .circular (16 );
25+ static const dragHandleHeight = 3.0 ;
26+ static const dragHandleVerticalMargin = 10.0 ;
2527
2628 final Map payload;
2729 final dynamic body;
@@ -132,7 +134,21 @@ class ShowBottomSheetAction extends EnsembleAction {
132134 }
133135
134136 Widget getBodyWidget (ScopeManager scopeManager, BuildContext context) {
135- var widget = scopeManager.buildWidgetFromDefinition (body);
137+ // We have to handle the BottomSheet's padding directly around the widget,
138+ // such that it is inside the Scrollable area to be able to move up and down.
139+ var sheetPadding = padding (scopeManager) ?? EdgeInsets .zero;
140+
141+ // account for the drag handle
142+ if (showDragHandle (scopeManager)) {
143+ var additionalPaddingTop =
144+ dragHandleVerticalMargin * 2 + dragHandleHeight;
145+ sheetPadding =
146+ sheetPadding.copyWith (top: sheetPadding.top + additionalPaddingTop);
147+ }
148+
149+ var widget = Padding (
150+ padding: sheetPadding,
151+ child: scopeManager.buildWidgetFromDefinition (body));
136152
137153 if (isScrollable (scopeManager) == true ) {
138154 // fix the viewport numbers if used incorrectly
@@ -159,7 +175,7 @@ class ShowBottomSheetAction extends EnsembleAction {
159175 // so the height will be fixed to initialViewport, and content will just scroll within it.
160176 // https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag
161177 return DraggableScrollableSheet (
162- expand: false ,
178+ expand: true ,
163179 minChildSize: minViewport,
164180 maxChildSize: maxViewport,
165181 initialChildSize: initialViewport,
@@ -181,8 +197,6 @@ class ShowBottomSheetAction extends EnsembleAction {
181197 Widget buildRootContainer (ScopeManager scopeManager, BuildContext context,
182198 {required Widget child, required bool isScrollable}) {
183199 Widget rootWidget = Container (
184- margin: margin (scopeManager),
185- padding: padding (scopeManager),
186200 decoration: BoxDecoration (
187201 color: getBackgroundColor (scopeManager) ??
188202 Theme .of (context).dialogBackgroundColor,
@@ -202,14 +216,17 @@ class ShowBottomSheetAction extends EnsembleAction {
202216 children: [rootWidget, _buildDragHandle (scopeManager)],
203217 );
204218 }
205- return rootWidget;
219+ // This is the Margin of the bottom sheet.
220+ // Padding will be handled separately inside the scrollable area
221+ return Padding (
222+ padding: margin (scopeManager) ?? EdgeInsets .zero, child: rootWidget);
206223 }
207224
208225 Widget _buildDragHandle (ScopeManager scopeManager) {
209226 return Container (
210- margin: const EdgeInsets .only (top: 10 ),
227+ margin: const EdgeInsets .only (top: dragHandleVerticalMargin ),
211228 width: 32 ,
212- height: 3 ,
229+ height: dragHandleHeight ,
213230 decoration: BoxDecoration (
214231 color: dragHandleColor (scopeManager) ?? Colors .grey[500 ],
215232 borderRadius: BorderRadius .circular (12 ),
0 commit comments