Created
December 13, 2020 13:17
-
-
Save rostand2017/1156d8f733f8d0c146d5f102b1d361f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Container( | |
child: Image.network( | |
Uri.parse(widget.url.small).toString(), | |
loadingBuilder: (BuildContext context, Widget widget, ImageChunkEvent imageChunk){ | |
if(imageChunk == null) | |
return widget; | |
final percentage = imageChunk!=null? imageChunk.cumulativeBytesLoaded / imageChunk.expectedTotalBytes : 0.0; | |
print("percentage: $percentage"); | |
return Container( | |
margin: EdgeInsets.all(8.0), | |
width: 50, | |
height: 50, | |
child: Stack( | |
textDirection: TextDirection.ltr, | |
children: [ | |
Opacity( | |
opacity: 0.4, | |
child: Icon(Icons.image, size: 50, color: _activeColor(),) | |
), | |
CircularProgressIndicator(backgroundColor: _activeColor(), value: percentage!=0? percentage : null,), | |
], | |
), | |
); | |
}, | |
errorBuilder: (BuildContext context, Object exception, StackTrace stackTrace) { | |
return Icon(Icons.broken_image, color: _activeColor(), size: 50,); | |
}, | |
), | |
padding: EdgeInsets.all(5.0), | |
decoration: BoxDecoration( | |
color: _getBgColors(), | |
borderRadius: BorderRadius.circular(10), | |
boxShadow: [ | |
BoxShadow( | |
color: Colors.grey.withOpacity(0.5), | |
spreadRadius: 1, | |
blurRadius: 2, | |
offset: Offset(0, 2), // changes position of shadow | |
), | |
], | |
), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment