
Use the RepaintBoundary component to wrap the canvas and specify the key. The main way to save albums is to introduce two plug-in libraries: permission_handler and image_gallery_saver, one for obtaining storage permissions and the other for saving to albums. When doing undo, call removeLast on list to remove the last item and refresh the screen to achieve the effect of a stroke back.
The second layer of loop is each stroke includes a number of coordinate points, traversal out to use drawLineMethod is drawn to the interface to form a line. The first cycle is to traverse all strokes, and the number of strokes traversed is the number of strokes of the character fu. Secondly, with the help of CustomPainter, we can draw the canvas by drawing all the dots into lines and using brushes on the interface.Ĭollect coordinate points: Listener( child: Container( alignment: Alignment.center, color: ansparent, width: double.infinity, height: MediaQuery.of(context).size.height, ), onPointerDown: (PointerDownEvent event), Copy the codeĪnd the previous said double traversal at this time also better understand: In onPointerDown onPointerMove, onPointerUp3 monitoring method in the returned PointerMoveEvent object contains the finger position coordinate offset localPosition, users will record every time sliding track after the coordinates of the point, These coordinate points together form a line. Use the Listener component to listen for the user's finger drops, slides, and drops. Implementation approach Display stroke trace
Save the written text style to the album.Click the undo button to clear the strokes drawn in the previous step.Click the Clear button to clear all strokes.The interface slides with the user's finger to show the track, that is, the corresponding stroke.How should Flutter achieve these functions? demand This activity includes the function of writing blessings by hand, revoking a stroke, erasing a rewrite, saving albums, etc. This morning, I woke up to find that alipay's annual activity of collecting five blessings has started again.
PK creative Spring Festival, I am participating in the "Spring Festival creative submission contest", please see: Spring Festival creative submission Contest