4Q-s-r-o / signature

Flutter plugin that creates a canvas for writing down a signature
MIT License
255 stars 85 forks source link

Dynamic color change for penColor #96

Open tushar0518 opened 10 months ago

tushar0518 commented 10 months ago

Since penColor, penStrokeWidth and other properties are final we can't change them dynamically. Like sometimes we need different colors in the same canvas with different strockWidth. Due to the above the current controller is overridden.

Currently is there a way to do it?

Here is my sample code,

final SignatureController _controller = SignatureController(
    penStrokeWidth: 4,
    penColor: Colors.red,
    exportBackgroundColor: Colors.transparent,
    exportPenColor: Colors.red,
    onDrawStart: () => log('onDrawStart called!'),
    onDrawEnd: () => log('onDrawEnd called!'),
  );
MaterialPicker(
              pickerColor: Colors.red,
              portraitOnly: true,
              onColorChanged: (Color color) {
                //on color picked
                print(color);
                _controller
                  ..penColor = color
                  ..penStrokeWidth = 4;
                setState(() {});
                Navigator.pop(context);
              },
            );

Screenshot 2023-12-21 at 11 41 34 AM

rohitbhoite commented 7 months ago

Added a change in below PR https://github.com/4Q-s-r-o/signature/pull/105