Skip to content

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

License

stephane-archer/flutter_solid_color_image_provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages