solid_color_image_provider 0.0.1 copy "solid_color_image_provider: ^0.0.1" to clipboard
solid_color_image_provider: ^0.0.1 copied to clipboard

A simple ImageProvider that generates a solid-color image for debugging and placeholders.

solid_color_image_provider #

A Flutter package providing a simple ImageProvider that generates a solid-color image. This is particularly useful for debugging UI layouts, placeholders, or testing image loading mechanisms without needing actual image assets.

Features #

  • Generates a solid-color image on the fly.
  • Customizable color, width, and height.
  • Extends ImageProvider, making it compatible with Image.image, DecorationImage, etc.
  • Lightweight and efficient for debugging purposes.

Installation #

Add this to your pubspec.yaml file:

dependencies:
  solid_color_image_provider: ^0.0.1 # Or the latest version

Then run flutter pub get.

Usage #

Import the package:

import 'package:solid_color_image_provider/solid_color_image_provider.dart';

Use it with Image.image or any widget that accepts an ImageProvider:

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

// A red 50x50 image (default)
Image(image: SolidColorImageProvider());

// A blue 100x200 image
Image(
  image: SolidColorImageProvider(
    color: Colors.blue,
    width: 100,
    height: 200,
  ),
);

// As a background image in a Container
Container(
  width: 300,
  height: 150,
  decoration: BoxDecoration(
    image: DecorationImage(
      image: SolidColorImageProvider(
        color: Colors.green,
        width: 300, // Should match container dimensions for best results
        height: 150,
      ),
      fit: BoxFit.cover,
    ),
  ),
  child: const Center(child: Text('Hello', style: TextStyle(color: Colors.white))),
);

Contributing #

Contributions are welcome! Please feel free to open an issue or submit a pull request.

1
likes
140
points
93
downloads

Publisher

unverified uploader

Weekly Downloads

A simple ImageProvider that generates a solid-color image for debugging and placeholders.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on solid_color_image_provider