👉 A versatile Flutter package for displaying images with various sources, including assets, SVGs, and
network images. The `ImageViewer` widget simplifies the integration of different image types,
providing customization options for dimensions, error handling, and border-radius.
👉 Parameters
imagePath | Path to the image, either an asset, SVG, or network URL ✅ |
imageType | Type of the image (ImageType.asset, ImageType.svg, ImageType.network) ✅ |
width and height | Dimensions of the image ❌ |
boxFit | BoxFit for the image ❌ |
errorIcon | Icon to display in case of loading errors ❌ |
imageColor | Color to apply to the image ❌ |
alignment | Alignment of the image within its container ❌ |
topLeftRadius, topRightRadius, bottomLeftRadius, bottomRightRadius | Border radiius for clipping ❌ |
👉 Show me the code 👀
enum ImageType { asset, svg, network }
ImageViewer(
imagePath: 'your_image_path',
imageType: ImageType.asset, // Change to your desired ImageType
// Add other optional parameters for customization
)
class MenuExample extends StatefulWidget {
@override
_MenuExampleState createState() => _MenuExampleState();
}
class _MenuExampleState extends State<MenuExample> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ImageViewer(
imagePath: 'http://via.placeholder.com/200x200',
imageType: ImageType.network,
width: 200,
height: 200,
boxFit: BoxFit.cover,
errorIcon: Icons.error_outline,
errorIconColor: Colors.blueGrey,
imageColor: Colors.blue,
alignment: Alignment.center,
topLeftRadius: 10,
topRightRadius: 20,
bottomLeftRadius: 30,
bottomRightRadius: 40,
),
),
);
}
}