It’s easy to customize image and related properties in flutter using FadeInImage.assetNetwork.
class CustomImage extends StatelessWidget {
final String image;
final double height;
final double width;
final BoxFit fit;
final String placeholder;
CustomImage({@required this.image, this.height, this.width, this.fit, this.placeholder});
@override
Widget build(BuildContext context) {
return FadeInImage.assetNetwork(
placeholder: Images.placeholder, height: height, width: width, fit: fit,
image: image,
imageErrorBuilder: (c, o, s) => Image.asset(
placeholder != null ? placeholder : Images.placeholder,
height: height, width: width, fit: fit,
),
);
}
}
We created a class called CustomImage and we pass parameters to it.
Network image path could be sent as string to this CustomImage class and pass down to FadeInImage.assetNetwork
Here Image.placeholder is the default image path. You can mention any image from assets path.