show method

Future<void> show()

Shows the image gallery after initialisation.

Implementation

Future<void> show() async {
  if (hideStatusBar)
    SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: []);
  var showOverlay = true;
  double _opacity = backgroundOpacity;

  final content = StatefulBuilder(
    builder: (context, setState) {
      void _setOpacity(double opacity) {
        setState(() {
          _opacity = opacity * backgroundOpacity;
        });
      }

      return Material(
        color: Colors.transparent,
        child: Stack(
          children: [
            GestureDetector(
              onTap: () {
                if (overlayController != null && hideOverlayOnTap) {
                  setState(() => showOverlay = !showOverlay);
                }
              },
              child: Gallery(
                children: children,
                itemBuilder: itemBuilder,
                itemCount: itemCount,
                initialIndex: initialIndex,
                dismissDragDistance: dismissDragDistance,
                backgroundColor: backgroundColor,
                transitionDuration: transitionDuration,
                controller: controller,
                onSwipe: onSwipe,
                heroProperties: heroProperties,
                opacity: _opacity,
                setBackgroundOpacity: _setOpacity,
              ),
            ),
            if (overlayController != null)
              GalleryOverlay(
                overlayController: overlayController!,
                showOverlay: showOverlay,
                opacity: _opacity,
                initialData: initialOverlay,
              ),
          ],
        ),
      );
    },
  );

  if (heroProperties != null) {
    await Navigator.of(context).push(
      PageRouteBuilder(
        opaque: false,
        barrierDismissible: true,
        fullscreenDialog: true,
        transitionDuration: Duration(milliseconds: transitionDuration),
        pageBuilder: (_, __, ___) => content,
      ),
    );
  } else {
    await showGeneralDialog(
      context: context,
      barrierColor: Colors.transparent,
      barrierDismissible: false,
      transitionDuration: Duration(milliseconds: transitionDuration),
      pageBuilder: (_, __, ___) => content,
    );
  }

  if (hideStatusBar)
    await SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
        overlays: SystemUiOverlay.values);
}