Skip to content

Instantly share code, notes, and snippets.

@GursheeshSingh
Created April 5, 2020 13:16
Show Gist options
  • Save GursheeshSingh/d0c95f5c151a3c821db3686e152adacd to your computer and use it in GitHub Desktop.
Save GursheeshSingh/d0c95f5c151a3c821db3686e152adacd to your computer and use it in GitHub Desktop.
//Add delete widget
Stack(
children: <Widget>[
InkWell(
onTap: () => _onPhotoClicked(index - 1),
child: Container(
margin: EdgeInsets.all(5),
height: 100,
width: 100,
color: kLightGray,
child: source == PhotoSource.FILE
? Image.file(image)
: Image.network(_photosUrls[index - 1]),
),
),
Visibility(
visible: _photosStatus[index - 1] == PhotoStatus.LOADING,
child: Positioned.fill(
child: SpinKitWave(
size: 25,
color: Colors.white,
),
),
),
Visibility(
visible: _photosStatus[index - 1] == PhotoStatus.ERROR,
child: Positioned.fill(
child: Icon(
MaterialIcons.error,
color: kErrorRed,
size: 35,
),
),
),
Positioned.fill(
child: Container(
padding: EdgeInsets.all(6),
alignment: Alignment.topRight,
child: DeleteWidget(
() => _onDeleteReviewPhotoClicked(index - 1),
),
),
)
],
);
//Add listener
Future<bool> _onDeleteReviewPhotoClicked(int index) async {
if (_photosStatus[index] == PhotoStatus.LOADED) {
_photosUrls.removeAt(index);
}
_photos.removeAt(index);
_photosStatus.removeAt(index);
_photosSources.removeAt(index);
_galleryItems.removeAt(index);
setState(() {});
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment