showImageViewerPager function

Future<Dialog?> showImageViewerPager(
  1. BuildContext context,
  2. EasyImageProvider imageProvider, {
  3. bool immersive = true,
  4. void onPageChanged(
    1. int
    )?,
  5. void onViewerDismissed(
    1. int
    )?,
  6. bool useSafeArea = false,
  7. bool swipeDismissible = false,
  8. bool doubleTapZoomable = false,
  9. bool infinitelyScrollable = false,
  10. Color backgroundColor = _defaultBackgroundColor,
  11. String closeButtonTooltip = _defaultCloseButtonTooltip,
  12. Color closeButtonColor = _defaultCloseButtonColor,
})

Shows the images provided by the imageProvider in a full-screen PageView Dialog. Setting immersive to false will prevent the top and bottom bars from being hidden. The optional onPageChanged callback function is called with the index of the image when the user has swiped to another image. The optional onViewerDismissed callback function is called with the index of the image that is displayed when the dialog is closed. The optional useSafeArea boolean defaults to false and is passed to showDialog. The optional swipeDismissible boolean defaults to false and allows swipe-down-to-dismiss. The optional doubleTapZoomable boolean defaults to false and allows double tap to zoom. The optional infinitelyScrollable boolean defaults to false and allows infinite scrolling. The backgroundColor defaults to black, but can be set to any other color. The closeButtonTooltip text is displayed when the user long-presses on the close button and is used for accessibility. The closeButtonColor defaults to white, but can be set to any other color.

Implementation

Future<Dialog?> showImageViewerPager(
    BuildContext context, EasyImageProvider imageProvider,
    {bool immersive = true,
    void Function(int)? onPageChanged,
    void Function(int)? onViewerDismissed,
    bool useSafeArea = false,
    bool swipeDismissible = false,
    bool doubleTapZoomable = false,
    bool infinitelyScrollable = false,
    Color backgroundColor = _defaultBackgroundColor,
    String closeButtonTooltip = _defaultCloseButtonTooltip,
    Color closeButtonColor = _defaultCloseButtonColor}) {
  if (immersive) {
    // Hide top and bottom bars
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);
  }

  return showDialog<Dialog>(
      context: context,
      useSafeArea: useSafeArea,
      builder: (context) {
        return EasyImageViewerDismissibleDialog(imageProvider,
            immersive: immersive,
            onPageChanged: onPageChanged,
            onViewerDismissed: onViewerDismissed,
            useSafeArea: useSafeArea,
            swipeDismissible: swipeDismissible,
            doubleTapZoomable: doubleTapZoomable,
            infinitelyScrollable: infinitelyScrollable,
            backgroundColor: backgroundColor,
            closeButtonColor: closeButtonColor,
            closeButtonTooltip: closeButtonTooltip);
      });
}