Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flood Fill Image

[![Version](https://img.shields.io/pub/v/floodfill_image.svg)](https://pub.dev/packages/floodfill_image) ![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat) [![Support](https://img.shields.io/badge/Buy%20Me%20Coffee-Support-orange?style=flat&logo=buy-me-a-coffee)](https://www.buymeacoffee.com/garlenjavier)
[![Version](https://img.shields.io/pub/v/floodfill_image.svg)](https://pub.dev/packages/floodfill_image) ![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg?style=flat) [![Support](https://img.shields.io/badge/Buy%20Me%20Coffee-Support-orange?style=flat&logo=buy-me-a-coffee)](https://ko-fi.com/garlen)

## Overview

Expand Down Expand Up @@ -40,7 +40,7 @@ FloodFillImage(

## Coffee

<a href="https://www.buymeacoffee.com/garlenjavier" target="_blank" rel="noreferrer"><img src="https://www.buymeacoffee.com/assets/img/custom_images/black_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>
<a href="https://ko-fi.com/garlen" target="_blank" rel="noreferrer"><img src="https://www.buymeacoffee.com/assets/img/custom_images/black_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

## License

Expand Down
132 changes: 82 additions & 50 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,72 +5,74 @@ packages:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
sha256: a92e39b291073bb840a72cf43d96d2a63c74e9a485d227833e8ea0054d16ad16
url: "https://pub.dev"
source: hosted
version: "3.1.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.1.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev"
source: hosted
version: "1.15.0"
version: "1.17.2"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
sha256: "8be10341257b613566fdc9fd073c46f7c032ed329b1c732bda17aca29f2366c8"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
sha256: caac504f942f41dfadcf45229ce8c47065b93919a12739f20d6173a883c5ec73
url: "https://pub.dev"
source: hosted
version: "1.0.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.3.1"
floodfill_image:
dependency: "direct main"
description:
Expand All @@ -92,37 +94,50 @@ packages:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
sha256: a72242c9a0ffb65d03de1b7113bc4e189686fc07c7147b8b41811d0dd0e0d9bf
url: "https://pub.dev"
source: hosted
version: "3.0.1"
version: "4.0.17"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev"
source: hosted
version: "0.12.16"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev"
source: hosted
version: "0.12.10"
version: "0.5.0"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
version: "1.9.1"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.8.3"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
sha256: cb3798bef7fc021ac45b308f4b51208a152792445cce0448c9a4ba5879dd8750
url: "https://pub.dev"
source: hosted
version: "4.0.2"
version: "5.4.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -132,65 +147,82 @@ packages:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev"
source: hosted
version: "1.8.0"
version: "1.10.0"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.11.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.1.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
url: "https://pub.dev"
source: hosted
version: "1.1.0"
version: "1.2.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
url: "https://pub.dev"
source: hosted
version: "1.2.0"
version: "1.2.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev"
source: hosted
version: "0.2.19"
version: "0.6.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee"
url: "https://pub.dev"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
url: "https://pub.dev"
source: hosted
version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "0.1.4-beta"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
sha256: "5bc72e1e45e941d825fd7468b9b4cc3b9327942649aeb6fc5cdbf135f0a86e84"
url: "https://pub.dev"
source: hosted
version: "5.0.2"
version: "6.3.0"
sdks:
dart: ">=2.12.0 <3.0.0"
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=1.17.0"
19 changes: 14 additions & 5 deletions lib/src/floodfill_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'dart:ui' as ui;
import 'floodfill_painter.dart';
import 'package:image/image.dart' as img;

class FloodFillImage extends StatefulWidget {
/// The image to display via [ImageProvider].
Expand Down Expand Up @@ -41,7 +42,7 @@ class FloodFillImage extends StatefulWidget {

/// Callback function that returns the touch position and an [Image] from *dart:ui* when flood fill starts.
/// <br>**Note:** Touch coordinate is relative to the image dimension.
final Function(Offset position,ui.Image image)? onFloodFillStart;
final Function(Offset position, ui.Image image)? onFloodFillStart;

/// Callback function that returns an [Image] from *dart:ui* when flood fill ended.
final Function(ui.Image image)? onFloodFillEnd;
Expand Down Expand Up @@ -101,7 +102,8 @@ class _FloodFillImageState extends State<FloodFillImage> {

void _getImage() {
final ImageStream? oldImageStream = _imageStream;
_imageStream = _imageProvider?.resolve(createLocalImageConfiguration(context));
_imageStream =
_imageProvider?.resolve(createLocalImageConfiguration(context));
if (_imageStream?.key != oldImageStream?.key) {
final ImageStreamListener listener = ImageStreamListener(_updateImage);
oldImageStream?.removeListener(listener);
Expand All @@ -116,7 +118,8 @@ class _FloodFillImageState extends State<FloodFillImage> {
_repainter = ValueNotifier("");
_painter = FloodFillPainter(
image: _imageInfo!.image,
fillColor: widget.fillColor,
fillColor: img.ColorRgba8(widget.fillColor.red, widget.fillColor.green,
widget.fillColor.blue, widget.fillColor.alpha),
notifier: _repainter,
onFloodFillStart: widget.onFloodFillStart,
onFloodFillEnd: widget.onFloodFillEnd,
Expand All @@ -136,7 +139,12 @@ class _FloodFillImageState extends State<FloodFillImage> {
@override
Widget build(BuildContext context) {
if (_painter != null) {
_painter?.setFillColor(widget.fillColor); //incase we want to update fillColor
final fillColor = img.ColorRgba8(
widget.fillColor.red,
widget.fillColor.green,
widget.fillColor.blue,
widget.fillColor.alpha);
_painter?.setFillColor(fillColor); //incase we want to update fillColor
_painter?.setAvoidColor(widget.avoidColor!);
_painter?.setTolerance(widget.tolerance);
_painter?.setIsFillActive(widget.isFillActive);
Expand Down Expand Up @@ -164,7 +172,8 @@ class _FloodFillImageState extends State<FloodFillImage> {

_painter!.setSize(Size(w, h));
return (widget.alignment == null)
? RepaintBoundary(child: CustomPaint(painter: _painter, size: Size(w, h)))
? RepaintBoundary(
child: CustomPaint(painter: _painter, size: Size(w, h)))
: Align(
alignment: widget.alignment!,
child: CustomPaint(painter: _painter, size: Size(w, h)));
Expand Down
Loading