showImageDialog function

void showImageDialog(
  1. BuildContext context,
  2. Uint8List bytes, {
  3. bool isSvg = true,
})

Implementation

void showImageDialog(
  BuildContext context,
  Uint8List bytes, {
  bool isSvg = true,
}) {
  showGeneralDialog(
    context: context,
    pageBuilder: (context, animation, secondaryAnimation) {
      return Center(
        child: Material(
          type: MaterialType.transparency,
          child: Stack(
            children: [
              Container(
                width: MediaQuery.of(context).size.width * 0.9,
                height: MediaQuery.of(context).size.height * 0.9,
                padding: const EdgeInsets.all(16.0),
                color: Colors.white,
                child: InteractiveViewer(
                  maxScale: 5,
                  child: isSvg ? SvgPicture.memory(bytes) : Image.memory(bytes),
                ),
              ),
              Positioned(
                top: 10,
                right: 10,
                child: GestureDetector(
                  onTap: () {
                    Navigator.of(context).pop();
                  },
                  child: const Icon(Icons.close, color: Colors.grey, size: 30),
                ),
              ),
            ],
          ),
        ),
      );
    },
    barrierDismissible: true,
    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
    transitionDuration: const Duration(milliseconds: 200),
  );
}