Giter Club home page Giter Club logo

flutter_painter's Introduction

Flutter Painter 🎨🖌️

pub package Buy Me A Pizza

A pure-Flutter package for painting.

Summary

Flutter Painter provides you with a widget that can be used to draw on it. Right now, it supports:

  • Free-style drawing: Scribble anything you want with any width and color.
  • Objects that you can move, scale and rotate in an easy and familiar way, such as:
    • Text with any TextStyle.
    • Shapes such as lines, arrows, ovals and rectangles with any Paint.
    • Images that can be flipped.
  • Free-style eraser to erase any part of a drawing or object you don't want on the painter.*

These are called drawables.

You can use a color or an image for the background of your drawing, and export your painting as an image.

Example

You can check out the example tab for an example on how to use the package.

The example is hosted here if you want to try it out yourself!

A video recording showing the example running:

Flutter Painter Video Demo

Usage

First, you'll need a PainterController object. The PainterController controls the different drawables, the background you're drawing on and provides the FlutterPainter widget with the settings it needs. Then, in your UI, use the FlutterPainter widget with the controller assigned to it.

class ExampleWidget extends StatefulWidget {
  const ExampleWidget({Key? key}) : super(key: key);

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

class _ExampleWidgetState extends State<ExampleWidget> {
  PainterController controller = PainterController();

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: 300,
      height: 300,
      child: FlutterPainter(
        controller: controller,        
      ),
    );
  }
}

You can also use the FlutterPainter.builder constructor, which uses a builder method that automatically updates whenever a change happens in the controller, without using setState, callbacks, or listeners. However, this will perform worse than a StatefulWidget since it will rebuild more often, so it is recommended to use if the widget tree that depends on PainterController is simple.

class ExampleWidget extends StatefulWidget {
  const ExampleWidget({Key? key}) : super(key: key);

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

class _ExampleWidgetState extends State<ExampleWidget> {
  PainterController controller = PainterController();

  @override
  Widget build(BuildContext context) {
    return FlutterPainter.builder(
      controller: controller,
      builder: (context, painter){
        return SizedBox(
          width: 300,
          height: 300,
          child: painter
        );
      }
    ); 
  }
}

NOTE: FlutterPainter does not define its own constraints on its size, so it is advised to use a widget that can provide its child with size constraints, such as SizedBox or AspectRatio (more on constraints here).

NOTE: If mutiple parts of your UI depend on the PainterController, you can use a ValueListeneableBuilder with the valueListenable being your controller, which will re-build automatically whenever the controller updates. This is the approach used in the example project.

Callbacks

FlutterPainter has some helpful callbacks that are called when internal changes happen in the widget itself.

  • onDrawableCreated: Called when a drawable is created from FlutterPainter. Passes the drawable as an arugment.
  • onDrawableDeleted: Called when a drawable is deleted from FlutterPainter. Passes the drawable as an arugment.
  • onSelectedObjectDrawableChanged: Called when the selected object drawable changes. This can be useful if you want to display some UI to edit the object's properties. Passes the selected object drawable as an argument.
    • If the drawable is updated (moved, for example), the passed drawable will become invalid. Make sure to use PainterController.selectedObjectDrawable to get the up-to-date value of the selected drawable.
  • onPainterSettingsChanged: Called when the settings of PainterController are changed from FlutterPainter itself. Passes the new settings as an argument.

PainterController

The PainterController is the heart of the operation of Flutter Painter. It controls the settings for FlutterPainter, its background, and all of its drawables, and the selected object drawable.

All setters on PainterController directly notify your FlutterPainter to respond and repaint. If you're using FlutterPainter.builder, the builder is automatically called to build the widget tree. If not, make sure to use setState and listen to the callbacks

NOTE: If you are using multiple painters, make sure that each FlutterPainter widget has its own PainterController, do not use the same controller for multiple painters.

Settings

There are currently three types of settings:

  • freeStyleSettings: They control the parameters used in drawing scribbles, such as the width and color. It also has a field to enable/disable scribbles, to prevent the user from drawing on the FlutterPainter.
  • textSettings: They mainly control the TextStyle of the text being drawn. It also has a focus node field (more on focus nodes here) to allow you to detect when the user starts and stops editing text.
  • objectSettings: These settings control objects that can be moved, scaled and rotated. Texts, shapes and images are all considered objects. It controls layout assist, which allows to center objects and rotate them at a right angle, and settings regarding the object controls for scaling, rotating and resizing.
  • shapeSettings: These control the paint and shape factory used (Shape Factory is used to create shapes), and whether the shape is drawn once or continiously.
  • scaleSettings: These settings control the scaling on the painter (zooming in/out). By default, scaling is disabled.

You can provide initial settings for the things you want to draw through the settings parameter in the constructor of the PainterController.

Each setting and sub-setting has extension setters and getters which you can use to read and modify the value of that setting.*

For example, this is how you would modify the stroke width of free-style drawings:

void setStrokeWidth(double value){
  controller.freeStyleStrokeWidth = value;
}

NOTE: If you're not using the extensions library, note that all of the settings objects are immutable and cannot be modified, so in order to change some settings, you'll have to create a copy of your current settings and apply the changes you need (this is similar to how you would copy ThemeData).

Background

You can also provide a background for the FlutterPainter widget from the controller. You can either use a color or an image as a background.

In order to use a color, you can simply call the backgroundDrawable extension getter on any color.*

void setBackground(){
  // Sets the background to the color black
  controller.background = Colors.black.backgroundDrawable;
}

In order to use an image, you will need an Image object from the dart library dart:ui. Since Flutter has an Image widget from the Material package, we'll refer to the image type we need as ui.Image.

import 'dart:ui' as ui;
ui.Image? myImage;

In order to get the ui.Image object from usual image sources (file, asset, network), you can use an ImageProvider with the image extension getter (Examples of ImageProvider: FileImage, MemoryImage, NetworkImage). This getter returns Future<ui.Image>.*

Then, you can use the backgroundDrawable extension getter on the ui.Image.*

void setBackground() async {
  // Obtains an image from network and creates a [ui.Image] object
  final ui.Image myImage = await NetworkImage('https://picsum.photos/960/720').image;
  // Sets the background to the image
  controller.background = myImage.backgroundDrawable;
}

The background can also be assigned from the constructor of PainterController directly.

Drawables

All the drawables drawn on FlutterPainter are stored and controller by the PainterController. On most use cases, you won't need to interact with the drawables directly. However, you may add, insert, replace or remove drawables from the code (without the user actually drawing them).

You can assign an initial list of drawables from the PainterController constructor to initialize the controller with them. You can also modify them from the controller, but be careful, use the methods from the PainterController itself and don't modify the drawables list directly.

DO:

void addMyDrawables(List<Drawable> drawables){
  controller.addDrawables(drawables);
}

DON'T:

void addMyDrawables(List<Drawable> drawables){
  controller.drawables.addAll(drawables);
}

Selected Object Drawable

PainterController also provides the currently-selected ObjectDrawable from the getter field PainterController.selectedObjectDrawable. This value stays up-to-date for any changes from the UI (the user selecting a new object drawable, for example). You can also programatically select and de-select an object drawable, granted it is in the list of drawables of the controller.

void selectObjectDrawable(ObjectDrawable drawable){
  controller.selectObjectDrawable(drawable);
}

void deselectObjectDrawable(){
  controller.deselectObjectDrawable();
}

The selected object drawable will also be automatically update if it is replaced or removed from the controller.

Rendering Image

From the PainterController, you can render the contents of FlutterPainter as a PNG-encoded ui.Image object. In order to do that, you need to provide the size of the output image. All the drawings will be scaled according to that size.

From the ui.Image object, you can convert it into a raw bytes list (Uint8List) in order to display it with Image.memory or save it as a file.

Uint8List? renderImage(Size size) async {
  final ui.Image renderedImage = await controller.renderImage(size);
  final Uint8List? byteData = await renderedImage.pngBytes;
  return byteData;
}

Notes

Erasing

Flutter Painter supports free-style erasing of drawables. However, whenever you use the erase mode, all object drawables will be locked in place and cannot be modified. This is done because erasing is just another layer, and if objects stayed movable, you'd be able to move from under and around erased areas of the painting, which doesn't make sense. If you un-do the action of using the erase mode, the objects will be unlocked again and you'll be able to move them.

Extensions

Flutter Painter consists of 3 libraries:

  • flutter_painter_pure, which contains all the APIs of Flutter Painter except for extensions on Flutter and Flutter Painter itself.
  • flutter_painter_extensions, which contains all the extensions defined and used by Flutter Painter.
  • flutter_painter which includes both previously mentioned libraries.

This is done so that people who don't want to use the extensions (conflicts, too many getters/setters, etc...) can use the pure library, and for people who only need the extensions to be able to import them alone.

If you're trying to use the extensions and they're showing as undefined, make sure you're importing the correct library.

Flutter Web

The html renderer for Flutter Web is not supported, and using it will cause unexpected behavior and errors (also includes the auto renderer which chooses the renderer depending on the device). If you're using it for Flutter Web, make sure to use --web-renderer canvaskit as an argument for your run/build commands. If you need to use auto or html for any reason (such as better performance), consider using another package.

If anybody is willing to help out the Flutter Web issue or with testing it would be highly appreciated (either contact me through my GitHub or contribute and post a pull request).

Support Me

If you like my work and would like to support me, feel free to do so :D

Buy Me A Pizza

flutter_painter's People

Contributors

auronchoo avatar friebetill avatar omarhurani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

flutter_painter's Issues

Issue with Flutter 3.10

Just updated to Flutter 3.10 and found the following error when building to ios simulator

Error (Xcode): ../../../.pub-cache/hosted/pub.dev/flutter_painter_v2-2.0.0/lib/src/views/widgets/object_widget.dart:1071:52: Error: The getter 'accentColor' isn't defined for the class 'ThemeData'.

Drawable Objects going off the canvas during Container resizing and do not positioned correctly

I noticed that the drawable object do not automatically resize during the main container resizing.

For an example I change the main container widget size during orientation change to use the max space available. background image is resized correctly. However drawable objects are not being resized and are not re-positioned when the parent widget size change.

Is there any solution to fix this unexpected behaviour?

image

Adding Image like stickers

Hi there, your package is awesome and I am using it in my new developed android app.
Maybe I am missing something , but can we add image like stickers to background?
It would be great if we can add some stickers like text functionality.

selectedDrawable opacity

I really like your package , it's great , but I hope.that it was possible to control the opacity of the selectedDrawable, just like we can flip the drawable by imageDrawable.copyWith(flipped: ...) , Controlling the opacity of the drawable is a very fitting feature , if it is already possible, could you give us a way to do it , thank you again for your package

Addition of new feature.

Hi
It's a great library!!!
Thanks for creating it.
Can we add Eraser functionality into this library?

Thanks.

Single Color Background

It is possible instead of using an image, to set a single color as the background?

Right now without using an image, I get a transparent background.

Background Images should change on swiping left or right retaining the drawing made on that image

As of now, there is one background image in this project, but I was looking to take multiple background images, and it should change on swiping right and left. Please help me with this. I am new to the flutter framework. Before finding this package I was working with the Scribble package and there I achieved this functionality using photo_view: ^0.14.0 but whenever I swipe to another image then the drawing too would go to the next image. The same case was happening when I was trying to Zoom. Please help me if it is possible in this project as I want the drawing to stay on that particular image and on swiping to the next image it should not carry forward the drawing and swiping back to the previous page, the drawing made on that should be retained. Please help me if possible. If that is not possible if there is somehow a way to show all the images on the same page instead of Swiping left or right.

(Handling multiple background images)

Picking an image from storage.

Instead of showing a network image in the initial image view, I want to pick an image from the local storage directory and edit it. Is it possible?

Position for Text widget

Hi,

Thank you for this great library!
I am facing position issue for text widget when used it for image editor which has zoom feature.

The text widget cursor position is not visible when image is zoomed in and panned somewhere not in the center of the image. So can we provide option to pass the position for TextDrawable from PainterController?

Thanks.

DrawableCreatedNotification Exception

If the user activates a draw shape tool and immediately performs a pinch/pan gesture flutter_painter throws an exception.

DrawableCreatedNotification(drawable) : super(drawable);
_TypeError (type 'Null' is not a subtype of type 'Drawable')

It appears the created event is triggered by the gesture which does not create the shape.

How can I listen: isDrawing

I want to listen the event of drawingStart, drawingUpdate, drawingEnd events. Is there a way to listen these events?

Widgets binding error after upgrading flutter version to 2.13.0-0.1.pre

I'm facing below warnings since I upgraded the flutter version to 2.13.0-0.1.pre.

Warnings:

Testing started at 10:59 AM ...
                      ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:32:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
                   ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:195:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
                   ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:205:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addObserver(this);
                   ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:211:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.removeObserver(this);
                   ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:279:34: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
    final value = WidgetsBinding.instance?.window.viewInsets.bottom;
                                 ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/object_widget.dart:107:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timestamp) {
                   ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.9.0/lib/flutter_redux.dart:474:22: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
      WidgetsBinding.instance?.addPostFrameCallback((_) {
                     ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_redux-0.9.0/lib/flutter_redux.dart:577:22: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../flutter/packages/flutter/lib/src/widgets/binding.dart').
      WidgetsBinding.instance?.addPostFrameCallback((_) {
                     ^

Flutter version:

Flutter 2.13.0-0.1.pre • channel unknown • unknown source
Framework • revision 13a2fb10b8 (8 days ago) • 2022-04-12 15:34:25 -0500
Engine • revision 499984f99c
ToolsDart 2.17.0 (build 2.17.0-266.1.beta) • DevTools 2.12.1

Angle draw

hey @omarhurani Library is awesome. Great work.
Would you please add different angle draw feature?

shap with text

when click on any shap how to add text with them like this image
IMG-20221002-WA0001

How to customize drawing tool?

Thank you for your nice work.

I've used this library for developing drawing app. But, I got some requirements, that is adding new texture drawing tool.

I want to new texture drawing tool. example.. below this image.
image

I don't know what I should do first.

plz. TT

Can't slide text font size

I run this package's example code.

When you try input text, you see keyboard open and slider above the keyboard.
But you can't slide them while keyboard open.
I think it's better idea that you can slide them while keyboard open.

i think there is a bug

Hi there, your package is awesome and I am using it in my new android app.
but i think there is a bug , when you add some text and you don't move it and then you add another text on the top of the previous one the first text convert to be like the second one .

Losing focus of text object

Hello, I'm opening a Modal for the user to choose the color that will be applied to the text, but opening the modal causes the text to lose focus. How can I refocus on text when Modal is closed to continue typing? I close the keyboard so that the modal has more space.

Thanks

Shapes outside popupmenubutton

I would like to draw the shapers inside a container and not in a popupmenu. Would it be possible to do this, do you have an example?

Thanks

Allow ability to draw dots

First of all, thank you for your plugin, it is very useful!

Would it be possible to draw points when clicking? Currently I have to move my finger a little before anything is drawn.

[Request] Rotating images

Right now, rotating the image using RotatedBox results in Drawables moving around in a weird way, so it would be nice if the PainterController had an option to rotate the images.

Done button required in iOS

Hi,

Great package. For add text feature we need to tap outside keyboard to close the keyboard. It would be better to have done button.

Thanks,
Subbarao

jpegBytes

Just as it is possible to obtain an image in png format (using the pngBytes extension) it would be useful to have it also in jpeg format, for example when the starting image is a jpeg.

Export drawables

Hi,
The package is awesome. I just want to ask a question that is there a way to export drawbles in the form of json. Like when we render the image, can we also export list of controller.drawables in json format or any other? Please reply me. And the package is awesome by the way.
I need this functionality for my project. So, if we cannot export drawables right now, please add this feature into this package. Thanks a million.

AssertionError_throwNew

The following error occurs whenever I try to move the slider in "Text settings".

@pragma("vm:external-name", "AssertionError_throwNew") external static _doThrowNew( int assertionStart, int assertionEnd, Object? message);

Image saving in local storage.

Hello,
I am trying to save the image in local storage using a path. But facing some issues. I was using your code but seems like I am unable to solve these errors.
image

Update package in pub.dev

Flutter 3.0 warning issues fixed by this PR

@omarhurani Kindly update package in pub.dev so that everyone get benefit because currently many people are using git version in their projects.

WidgetBinding error after upgrading to Flutter 3.0

Log:

 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('.fvm/flutter_sdk/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
                   ^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:195:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('.fvm/flutter_sdk/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
                   ^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:205:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('.fvm/flutter_sdk/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addObserver(this);
                   ^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:211:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('.fvm/flutter_sdk/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.removeObserver(this);
                   ^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:279:34: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('.fvm/flutter_sdk/packages/flutter/lib/src/widgets/binding.dart').
    final value = WidgetsBinding.instance?.window.viewInsets.bottom;
                                 ^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/object_widget.dart:107:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('.fvm/flutter_sdk/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timestamp) {
                   ^```

Using flutter_painter with PageView.builder increases the memory of the application

I am using flutter painter library in Page of PageView.builder. I am opening multiple images in different pages of PageView. I have created different PainterController of each page as suggested by document.
But whenever I switched to next image it is increasing the memory. So I have many images and when I switched to many images then my application crashing due to too much memory uses.
I have dispose each and every painter_controller when switched to next page but nothing is working.

Can you please help me on that I am new in flutter.
Thanks in advance.
memory_tracking

flutter_painter: ^1.0.0 error on flutter sdk 3.0.5

/C:/flutter/flutter_3.0.5/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:32:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.

  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/flutter_3.0.5/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
    ^
    /C:/flutter/flutter_3.0.5/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:195:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/flutter_3.0.5/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timeStamp) {
    ^
    /C:/flutter/flutter_3.0.5/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:205:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/flutter_3.0.5/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addObserver(this);
    ^
    /C:/flutter/flutter_3.0.5/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:211:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/flutter_3.0.5/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.removeObserver(this);
    ^
    /C:/flutter/flutter_3.0.5/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/text_widget.dart:279:34: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/flutter_3.0.5/packages/flutter/lib/src/widgets/binding.dart').
    final value = WidgetsBinding.instance?.window.viewInsets.bottom;
    ^
    /C:/flutter/flutter_3.0.5/.pub-cache/hosted/pub.dartlang.org/flutter_painter-1.0.1/lib/src/views/widgets/object_widget.dart:107:20: Warning: Operand of null-aware operation '?.' has type 'WidgetsBinding' which excludes null.
  • 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('/C:/flutter/flutter_3.0.5/packages/flutter/lib/src/widgets/binding.dart').
    WidgetsBinding.instance?.addPostFrameCallback((timestamp) {

Go Back Swipe

It appears to exist a bug for which is not possible to remove the swipe gesture to navigate back in flutter.

Flutter 2.10.3 • channel stable 
Dart 2.16.1

It is not possible to remove it disabling it completely with WillPopScope because even if it doesn't go back on the gesture it won't start drawing if it is been tapped on the left side. (from the right side too)

I wonder if anyone has already encountered the same problem and solved it somehow?

Requesting for crop image

hello, flutter painter is awesome package for notes and draw. It will be more awesome if you will add crop feature of image. Or you can suggest us how we will do this.

Text renders new lines incorrectly

I think I found a bug with the text. When you add text and write enough that it gets wrapped onto a new line it looks like image 1. However, when you render this, the text gets cut off and it looks like image 2. The screenshots are from the web example. Btw, thank you so much for making this package, I really like it.

Screen Shot 2022-02-07 at 8 40 02 PM

Screen Shot 2022-02-07 at 8 40 26 PM

A clear icon button to clear the canvas at once (Suggestion)

According to me, a clear icon button should be provided to clear the canvas i.e. clear all the scribblings, stickers, or text which are placed on the canvas. As it would be very handy if people want to delete everything in one go. Presently doing undoredo or erasing by the eraser is time-consuming. I have seen this feature in the Scribble package which increases people's convenience.

Not working on lower version

This plugin is not supported in without null safety.
Getting this error:
This error getting in ObjectWidget class. size parameters is not getting.
final newDrawable = drawable.copyWith( size: Size( vertical ? drawable.size.width : totalLength, vertical ? totalLength : drawable.size.height, ), position: initial.position + position, // scale: scale, // rotation: assistedRotation, // assists: assists, );

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.