diff --git a/lib/utils/as_grid_image_view.dart b/lib/utils/as_grid_image_view.dart index 4adba26..0ffcd8c 100644 --- a/lib/utils/as_grid_image_view.dart +++ b/lib/utils/as_grid_image_view.dart @@ -12,21 +12,19 @@ class AsGridImageView extends StatelessWidget { final void Function(dynamic value)? onDelete; final double? iconSize; - const AsGridImageView.fromFile( - {Key? key, - required this.files, - this.placeholder, - this.onDelete, - this.iconSize}) + const AsGridImageView.fromFile({Key? key, + required this.files, + this.placeholder, + this.onDelete, + this.iconSize}) : nets = null, super(key: key); - const AsGridImageView.fromNets( - {Key? key, - required this.nets, - this.placeholder, - this.onDelete, - this.iconSize}) + const AsGridImageView.fromNets({Key? key, + required this.nets, + this.placeholder, + this.onDelete, + this.iconSize}) : files = null, super(key: key); @@ -43,58 +41,58 @@ class AsGridImageView extends StatelessWidget { shrinkWrap: true, children: files == null ? nets! - .map((e) => GestureDetector( - onTap: () => PhotoViewer.fromNet( - context, - tag: e, - net: e, - ), - child: Stack( - children: [ - Hero( - tag: e, - child: FadeInImage.assetNetwork( - placeholder: placeholder ?? '', image: e), - ), - Positioned( - top: size / 2, - right: size / 2, - child: GestureDetector( - onTap: () { - if (onDelete == null) { - onDelete!(e); - } - }, - child: Icon( - CupertinoIcons.xmark_circle_fill, - color: Colors.black45, - ), - )) - ], - ), - )) - .toList() + .map((e) => + GestureDetector( + onTap: () => + PhotoViewer.fromNet( + context, + tag: e, + net: e, + ), + child: Stack( + children: [ + Hero( + tag: e, + child: FadeInImage.assetNetwork( + placeholder: placeholder ?? '', image: e), + ), + if(onDelete != null) Positioned( + top: size / 2, + right: size / 2, + child: GestureDetector( + onTap: () { + onDelete!(e); + }, + child: Icon( + CupertinoIcons.xmark_circle_fill, + color: Colors.black45, + ), + )) + ], + ), + )) + .toList() : files! - .map((e) => Stack(children: [ - Positioned( - top: 0, - right: 0, - child: GestureDetector( - onTap: () { - if (onDelete != null) { - onDelete!(e); - } - }, - child: Icon( - CupertinoIcons.xmark_circle_fill, - color: Colors.black45, - ), - )), - GestureDetector( - onTap: () => PhotoViewer.fromFile(context, - tag: e.path, file: e), - child: Hero(tag: e.path, child: Image.file(e))) - ])) - .toList()); + .map((e) => + Stack(children: [ + if(onDelete != null) Positioned( + top: 0, + right: 0, + child: GestureDetector( + onTap: () { + onDelete!(e); + }, + child: Icon( + CupertinoIcons.xmark_circle_fill, + color: Colors.black45, + ), + )), + GestureDetector( + onTap: () => + PhotoViewer.fromFile(context, + tag: e.path, file: e), + child: Hero(tag: e.path, child: Image.file(e))) + ])) + .toList()); } }