showMorphSheet function

MorphFlight showMorphSheet(
  1. BuildContext context, {
  2. Object? from,
  3. required MorphContentBuilder builder,
  4. double? height,
  5. double heightFactor = 0.5,
  6. double maxWidth = 560,
  7. MorphSurfaceSpec? surface,
  8. ShapeBorder? shape,
  9. Color? surfaceColor,
  10. MorphMotion? motion,
  11. bool barrierDismissible = true,
  12. double? maxScrimOpacity,
  13. Color? scrimColor,
  14. Color? shadowColor,
  15. VoidCallback? onDismissRequested,
  16. String? semanticLabel,
})

The sheet adopts its look from the app's BottomSheetTheme (shape, color) unless overridden explicitly: a morph sheet inside a foreign design system looks native with zero configuration.

Implementation

MorphFlight showMorphSheet(
  BuildContext context, {
  Object? from,
  required MorphContentBuilder builder,
  double? height,
  double heightFactor = 0.5,
  double maxWidth = 560,
  MorphSurfaceSpec? surface,
  ShapeBorder? shape,
  Color? surfaceColor,
  MorphMotion? motion,
  bool barrierDismissible = true,
  double? maxScrimOpacity,
  Color? scrimColor,
  Color? shadowColor,
  VoidCallback? onDismissRequested,
  String? semanticLabel,
}) {
  assert(
    height == null || height > 0,
    'height must be positive; omit it to use heightFactor.',
  );
  assert(
    heightFactor > 0 && heightFactor <= 1,
    'heightFactor is a fraction of the screen height in (0, 1]; '
    'got $heightFactor. For a fixed size pass height instead.',
  );
  assert(maxWidth > 0, 'maxWidth must be positive.');
  final BottomSheetThemeData theme = Theme.of(context).bottomSheetTheme;
  return showMorph(
    context,
    from: from,
    target: MorphTargetSpec.sheet(
      height: height,
      heightFactor: heightFactor,
      maxWidth: maxWidth,
      surface: surface,
      shape: shape ?? theme.shape,
      surfaceColor: surfaceColor ?? theme.backgroundColor,
    ),
    builder: builder,
    motion: motion,
    barrierDismissible: barrierDismissible,
    maxScrimOpacity: maxScrimOpacity,
    scrimColor: scrimColor,
    shadowColor: shadowColor,
    onDismissRequested: onDismissRequested,
    semanticLabel: semanticLabel,
  );
}