floodfill_image 0.0.8 copy "floodfill_image: ^0.0.8" to clipboard
floodfill_image: ^0.0.8 copied to clipboard

Flutter widget that can use paint bucket functionality on the provided image.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flood Fill Image Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flood Fill Image Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String? title;
  MyHomePage({Key? key, this.title}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Color _fillColor = Colors.amber;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title!),
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              FloodFillImage(
                imageProvider: AssetImage("assets/dog.jpg"),
                fillColor: _fillColor,
                avoidColor: [Colors.transparent, Colors.black],
                tolerance: 10,
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceAround,
                children: [
                  TextButton(
                    onPressed: () {
                      setState(() {
                        _fillColor = Colors.brown;
                      });
                    },
                    child: Text("Brown",style: TextStyle(color: Colors.black),),
                    style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.brown)),
                  ),
                  TextButton(
                    onPressed: () {
                      setState(() {
                        _fillColor = Colors.amber;
                      });
                    },
                    child: Text("Amber",style: TextStyle(color: Colors.black),),
                    style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.amber)),
                  ),
                  TextButton(
                    onPressed: () {
                      setState(() {
                        _fillColor = Colors.cyan;
                      });
                    },
                    child: Text("Cyan",style: TextStyle(color: Colors.black),),
                    style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Colors.cyan)),
                  ),
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}
70
likes
140
points
112
downloads

Publisher

verified publishermeekcode.com

Weekly Downloads

Flutter widget that can use paint bucket functionality on the provided image.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, image

More

Packages that depend on floodfill_image