# image_show

A versatile Flutter widget to display images from network or asset sources, supporting JPG, PNG, and SVG formats with a customizable fallback icon. It uses `flutter_screenutil` for responsive sizing.

---

## โœจ Features

- ๐Ÿ“ก Load images from network URLs (`http/https/dio`)
- ๐Ÿ“ Load images from local asset paths
- ๐Ÿ–ผ๏ธ Supports JPG, PNG, and SVG formats
- ๐Ÿงฉ Customizable fallback icon if image fails to load or is null/empty
- ๐Ÿ“ฑ Responsive sizing using `.h`, `.w` from `flutter_screenutil`
- ๐ŸŽจ Flexible styling options: height, width, fit, border radius, background color, and border

---

## ๐Ÿš€ Installation

Add the following to your `pubspec.yaml`:

```yaml
dependencies:
  image_show_widget: ^0.1.0 # Use the latest version
  flutter_svg: ^2.0.10 # Required for SVG support
  flutter_screenutil: ^5.9.0 # Required for responsive sizing

Then run:

flutter pub get

๐Ÿ› ๏ธ Setup

You must initialize ScreenUtil in your main.dart:

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(360, 690), // Set your design size
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, child) {
        return MaterialApp(
          title: 'ImageShow Demo',
          home: child,
        );
      },
      child: const MyHomePage(),
    );
  }
}

๐Ÿ“ฆ Usage

Import the package:

import 'package:image_show/image_show.dart';

Use the ImageShow widget:

ImageShow(
  imagePath: 'https://your_image_url_or_asset_path',
  width: 100, // Scaled responsively
  height: 100,
  boxFit: BoxFit.cover,
  borderRadius: BorderRadius.circular(8.0),
  defaultIcon: Icons.person,
  defaultIconSize: 50,
  defaultIconColor: Colors.grey,
  backgroundColor: Colors.blueGrey[100],
  border: Border.all(color: Colors.blueGrey, width: 1),
)

๐Ÿงช Example

Column(
  children: [
    ImageShow(
      imagePath: 'https://tinyurl.com/flutter-logo',
      width: 150,
      height: 150,
      borderRadius: BorderRadius.circular(75),
      backgroundColor: Colors.blueGrey[100],
      defaultIcon: Icons.image_not_supported,
      defaultIconColor: Colors.red,
    ),
    SizedBox(height: 20.h),
    ImageShow(
      imagePath: 'assets/my_local_image.png',
      width: 100,
      height: 100,
      boxFit: BoxFit.contain,
    ),
    SizedBox(height: 20.h),
    ImageShow(
      imagePath: null,
      width: 80,
      height: 80,
      defaultIcon: Icons.person,
      defaultIconSize: 60,
      defaultIconColor: Colors.purple,
      backgroundColor: Colors.purple[50],
      borderRadius: BorderRadius.circular(40),
    ),
    SizedBox(height: 20.h),
    ImageShow(
      imagePath: 'https://example.com/non_existent_image.jpg',
      width: 120,
      height: 120,
      defaultIcon: Icons.error_outline,
      defaultIconColor: Colors.orange,
      border: Border.all(color: Colors.orange, width: 2),
    ),
  ],
)

๐Ÿ“‹ Parameters

Parameter Type Description Default Required
imagePath String? Path to image (URL or asset). Shows default icon if invalid. null โŒ
height double? Height scaled with .h. Defaults to 100.h. null โŒ
width double? Width scaled with .w. Defaults to full screen width. null โŒ
boxFit BoxFit? How to fit the image inside the container. BoxFit.cover โŒ
borderRadius BorderRadius? Corner radius of the image container. BorderRadius.zero โŒ
defaultIcon IconData Fallback icon if image is null or fails. Icons.person โŒ
defaultIconSize double Size of the fallback icon. 50.0 โŒ
defaultIconColor Color Color of the fallback icon. Colors.grey โŒ
backgroundColor Color? Background color of the container. null โŒ
border BoxBorder? Optional border around the image. null โŒ

๐Ÿค Contributing

Contributions are welcome! Feel free to submit a PR or open an issue.


๐Ÿ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.



Let me know if you want me to generate this into an actual `README.md` file or push to GitHub.

Libraries

image_show