flutter_drawing_board icon indicating copy to clipboard operation
flutter_drawing_board copied to clipboard

Online Streaming

Open Alijaaan opened this issue 3 years ago • 5 comments

Is there any way to use this package for online whiteboard?

Alijaaan avatar Oct 21 '22 07:10 Alijaaan

Of course. You'd have to set up a socket server and pass the drawing data between the clients.

The DrawingBoard widget contains parameters for you to listen/react to the changes on the drawing board. There are 3 of them: onPanStart, onPanUpdate and onPanEnd.

The controller for that widget, DrawingController contains methods that allow you to programmatically draw on the canvas, namely, controller.drawing, controller.startDraw and controller.endDraw. The first two takes an offset parameter.

You can then have a socket server which from one client emits offset from onPanStart, onPanUpdate and onPanEnd and for each event call the respective function on the receiving client with the offset parameter passed to programmatically draw on the canvas.

Chappie74 avatar Oct 23 '22 19:10 Chappie74

Many thanks for your great answer. I did it but still have one problem, I have no problem with SimpleLine and it works fine. But in other types like circle or rectangle I cant handle it.

Alijaaan avatar Oct 24 '22 15:10 Alijaaan

I found that I should do something like this on destination: _drawingController?.setPaintContent = Rectangle(); Many thanks for your kind help :) But I still can't detect the Delete or undo etc. buttons;

Alijaaan avatar Oct 24 '22 16:10 Alijaaan

Yes. You have to set up socket emits for all of that. What I have is a "tool_changed" I listen for. My tools are in an array, which I loop though to render. When one user changes tools, I just emit the index of that specific tool in the array and on the receiving end, changed the currently selected tool to that index, by calling the set paint function you mentioned. Screenshot_20221026-102135.jpg

Chappie74 avatar Oct 26 '22 14:10 Chappie74

If you would like, we can discuss on discord.

Chappie74#9006

Chappie74 avatar Oct 26 '22 14:10 Chappie74