Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/sheet_content_wrapper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class _SheetContentWrapperState extends State<SheetContentWrapper> {
Widget build(BuildContext context) {
if (widget.sheetData == null) return SizedBox();
return widget.sizeCalculator.positionWidget(
child: _wrapWithNecessaryWidgets(widget.sheetData!.child),
child: _wrapWithNecessaryWidgets(widget.sheetData!
.buildConstrainedChild(widget.sizeCalculator.maxHeight)),
);
}
}
9 changes: 8 additions & 1 deletion lib/src/sheet_size_behaviors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ abstract class SheetSizeBehavior {

/// Fills the available hight in a sheet.
class SheetSizeFill implements SheetSizeBehavior {
const SheetSizeFill();
/// If set to `true`, the [SnappingSheetContent.child] will be constrained
/// to the sheet's visible area as it expands.
///
/// Otherwise, it will be constrained to the maximum size that the sheet can
/// expand to, and clipped.
final bool constrainToVisibleArea;

const SheetSizeFill({this.constrainToVisibleArea = true});
}

/// Make the sheet have a static height.
Expand Down
16 changes: 12 additions & 4 deletions lib/src/snapping_sheet_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,22 @@ class SnappingSheetContent {
this.childScrollController,
}) : this._child = child;

double? _getHeight() {
double? _getHeight(double maxHeight) {
var sizeBehavior = this.sizeBehavior;
if (sizeBehavior is SheetSizeStatic) return sizeBehavior.height;
if (sizeBehavior is SheetSizeFill && !sizeBehavior.constrainToVisibleArea)
return maxHeight;
}

Widget get child {
return SizedBox(
height: _getHeight(),
Widget buildConstrainedChild(double maxHeight) {
assert(location != SheetLocation.unknown,
'The location must be known to constrain the child!');
return OverflowBox(
alignment: location == SheetLocation.above
? Alignment.bottomCenter
: Alignment.topCenter,
minHeight: _getHeight(maxHeight),
maxHeight: _getHeight(maxHeight),
child: this._child,
);
}
Expand Down