4Q-s-r-o / signature

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

Exported width cannot be smaller than actual width #65

Closed Bestfastfire closed 2 years ago

Bestfastfire commented 2 years ago

This line:

final ui.Image? image = await toImage(height: 500, width: 400);

Height and width has a fixed value, it causing the issue:

Failed assertion: line 413 pos 9: '((width ?? defaultWidth!) - defaultWidth!) >= 0.0': Exported width cannot be smaller than actual width

When I try: _controller.toPngBytes();

Because my Signature widget has the my screen size, and that has: Width: 375px Height: 812px

How 375 is smaller then the default value 400, I cannot export, my commit fix that making possible change this value by method parameters.

This occurs because I am using the landscape mode in the application.

Arcttyx commented 2 years ago

Also, fixed height and width causes rendering of images with small signatures and too much background space when converting bytes to image.

For example, use a 300x300 space. If the user only draws to the center using a small part of that space and _controller.toPngBytes() is used to save the signature. Then when you want to display the signature elsewhere, it will be displayed small, centered with plenty of space around the signature as a result.

MartinHlavna commented 2 years ago

Hi, thanks for PR. I am closing this in favor of #69 which solves the same issue. Solution is essentially same, but there are another good contributions.