showGlimpse function

Future<void> showGlimpse({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. bool rootNavigator = true,
  4. bool draggable = true,
  5. bool dismissible = true,
  6. BoxConstraints constraints = const BoxConstraints.tightFor(height: 450),
  7. double margin = 10,
  8. Color? backgroundColor,
  9. BorderRadiusGeometry? borderRadius,
})

Shows a glimpse view (AirPods-like popup)

This function shows a glimpse view using GlimpseModalRoute. It is a wrapper around Navigator.of(context).push. It is recommended to use this function instead of Navigator.of(context).push.

builder is the builder for the glimpse view. It is required. rootNavigator determines whether the glimpse view should be pushed to the root navigator. draggable determines whether the glimpse view can be dragged up and down. dismissible determines whether the glimpse view can be dismissed by dragging it down or by tapping on the barrier. constraints is the constraints for the glimpse view. It defaults to a height of 450. margin is the margin around the glimpse view. It defaults to 10. backgroundColor is the background color of the glimpse view. It defaults to the scaffold background color. borderRadius is the border radius for the glimpse view. It defaults to a circular border radius with a minimum of 20.

Implementation

Future<void> showGlimpse({
  required BuildContext context,
  required WidgetBuilder builder,
  bool rootNavigator = true,
  bool draggable = true,
  bool dismissible = true,
  BoxConstraints constraints = const BoxConstraints.tightFor(height: 450),
  double margin = 10,
  Color? backgroundColor,
  BorderRadiusGeometry? borderRadius,
}) async {
  initializeGlimpse().then((_) {
    Navigator.of(
      context,
      rootNavigator: rootNavigator,
    ).push(GlimpseModalRoute(
      builder: builder,
      draggable: draggable,
      dismissible: dismissible,
      constraints: constraints,
      margin: margin,
      backgroundColor: backgroundColor,
      borderRadius: borderRadius,
    ));
  });
}