yellowQ-software / yellowQ-Flutter-Image-Painter

Flutter package for painting on images
MIT License
106 stars 117 forks source link

store paintHistory and access that again #3

Closed wahidanvary closed 3 years ago

wahidanvary commented 3 years ago

Is there possible to store paintHistory or drawn data on my server then reload those data again at another time? Thank you for your help...

lively-bigyan commented 3 years ago

PaintHistory is a map of mode and the paint info, so it is possible to store the history but it is inadvisable to do so with the current implementation of the package. While I haven't tried out the implementation, it should be possible but that requires exposing the paintHistory as public variable. In next implementation all the utils will be held on the controller thus not involving globalKey to access functions. By then you are free to fork the project and make paintHistory i.e. List<PaintHistory> _paintHistory public to try and see how it goes. :smile:

wahidanvary commented 3 years ago

Hi again dear @lively-bigyan, I made several attempts to access the PaintHistory but unfortunately did not succeed. I also made a fork but did not realize which part I needed to change exactly to work. Can you explain an exact solution?

lively-bigyan commented 3 years ago

In the package, there is a _paintHistory variable which keeps track of the all the modes and co-ordinates as well as the paint method. It is technically possible because painthistory is a kind of data and it can be converted to json and stored in the storage and fetched again. Basically, you'll need to make a PaintHistory.fromMap and toMap in the PaintHistory Model where you can convert the paintHistory to json back and forth and on initialization of Imagepainter you would need to add the json data converting into painthistory object to the painthistory.

While I cannot guide you through the exact steps, these are the things I would do if it were upto me. It is not recommended because it should be done in exact same device to exact same image to replicate the result otherwise it would be sort of pointless. So it is not the highest of priority for me right now but I would be willing to do it as an experiment whenever I get some free time.

wahidanvary commented 3 years ago

I could do that with provider package. Thank you.

Goddard commented 2 years ago

Isn't the scale default of 1 the limiting factor so if the image is the same size as previous it will be able to be loadable without any modifications no matter the device you are using?