MorphTargetSpec.sheet constructor
- double? height,
- double heightFactor = 0.5,
- double maxWidth = 560,
- double margin = 14,
- MorphSurfaceSpec? surface,
- ShapeBorder? shape,
- Color? surfaceColor,
A bottom sheet: full-width up to maxWidth, docked above the
bottom safe area.
Implementation
factory MorphTargetSpec.sheet({
double? height,
double heightFactor = 0.5,
double maxWidth = 560,
double margin = 14,
MorphSurfaceSpec? surface,
ShapeBorder? shape,
Color? surfaceColor,
}) {
return MorphTargetSpec(
surface: surface,
shape:
shape ??
const RoundedRectangleBorder(borderRadius: .all(.circular(28))),
surfaceColor: surfaceColor,
rectFor: (Size size, EdgeInsets padding) {
// Floors at zero: an overlay narrower than its margins (a
// collapsing split pane) must degrade to an empty rect, not
// feed negative constraints to the shuttle.
final double w = math.max(
0,
math.min(maxWidth, size.width - margin * 2),
);
final double desired = height ?? size.height * heightFactor;
final double h = math.max(
0,
math.min(
desired,
size.height - padding.top - padding.bottom - margin * 2,
),
);
return Rect.fromLTWH(
(size.width - w) / 2,
size.height - h - padding.bottom - margin,
w,
h,
);
},
);
}