show method

Future<void> show()

Implementation

Future<void> show() async {
  double opacity = 1;
  int activeIndex = initialIndex ?? 0;
  await showGeneralDialog(
    context: context,
    barrierDismissible: false,
    transitionDuration: const Duration(milliseconds: 400),
    pageBuilder: (context, animation, secondaryAnimation) => StatefulBuilder(
      builder: (context, setState) {
        return Material(
          color: Colors.transparent,
          child: Container(
            decoration: BoxDecoration(
                color: backgroundColor ?? Colors.black.withOpacity(opacity),
                gradient: backgroundGradient),
            child: SafeArea(
              child: Stack(
                alignment: Alignment.center,
                fit: StackFit.expand,
                children: [
                  PageView.builder(
                    itemCount: imagePaths.length + 1,
                    controller:
                        PageController(initialPage: initialIndex ?? 0),
                    onPageChanged: (index) {
                      if (index == imagePaths.length) {
                        Navigator.of(context).pop();
                      } else {
                        onSwipe?.call(index);
                      }

                      Future.microtask(() => setState(() {
                            activeIndex = index;
                          }));
                    },
                    itemBuilder: (context, index) {
                      if (index == imagePaths.length) {
                        return const SizedBox();
                      }
                      return _AVSImageOnePage(
                        setBackgroundOpacity: (p0) {
                          opacity = p0;
                          Future.microtask(() => setState(() {}));
                        },
                        child: AVSImage(
                          imagePaths[index],
                          zoom: false,
                        ),
                      );
                    },
                  ),
                  showCloseButton == true
                      ? Positioned(
                          top: 20,
                          right: 20,
                          child: IconButton(
                            onPressed: () => Navigator.pop(context),
                            icon:
                                const Icon(Icons.close, color: Colors.white),
                          ),
                        )
                      : const SizedBox(),

                  // Bottom Bar
                  showBottomBar == false
                      ? const SizedBox()
                      : Positioned(
                          bottom: 20,
                          child: SizedBox(
                            height: 9,
                            child: ListView.builder(
                              itemCount: imagePaths.length,
                              scrollDirection: Axis.horizontal,
                              shrinkWrap: true,
                              itemBuilder: (context, index) {
                                return Container(
                                  height: 9,
                                  width: 9,
                                  margin: const EdgeInsets.symmetric(
                                      horizontal: 2),
                                  decoration: BoxDecoration(
                                    color: activeIndex == index
                                        ? Colors.white.withOpacity(opacity)
                                        : Colors.grey.withOpacity(opacity),
                                    shape: BoxShape.circle,
                                  ),
                                );
                              },
                            ),
                          ),
                        ),
                ],
              ),
            ),
          ),
        );
      },
    ),
  );
}