4Q-s-r-o / signature

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

Unexpected draw behaviour #58

Closed umer322 closed 2 years ago

umer322 commented 2 years ago

If i set signature inside expanded in row widget and don't specify width i am able to draw out side of signature widget. For test purpose: Row( children: [ Expanded(child: AutoSizeText("Citizen Signature")), Flexible( flex: 2, child: Signature( controller: SignatureController( penStrokeWidth: 5, penColor: Colors.black, exportBackgroundColor: Colors.blue, ), height: height * 0.1, backgroundColor: Colors.grey[300]!, ) ) ], )

cihancil commented 2 years ago

Same here. If I don't set a width and height for Signature widget, I can draw outside of its border. It doesn't need to be inside Row.

MartinHlavna commented 2 years ago

Fix released in 5.0.1

cfsbhawkins commented 2 years ago

I don't think this is fixed. Using 5.0.1, even added a row and flexible around it like in sample.

Screenshot_1652820904

return Column(children: [ Row( children: [ Flexible( flex: 2, child: Signature( controller: _signatureController, backgroundColor: CoreTheme.gray, height: 100, )) ], ), Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: TextFormField( minLines: 1, maxLines: 1, textCapitalization: TextCapitalization.words, keyboardType: TextInputType.name, decoration: InputDecoration( hintText: 'Type Signatory Name', hintStyle: CoreTheme.textStyleParagraph(color: FontColor.gray), border: InputBorder.none, ), onSaved: (name) => onValueChanged(context, name: name) ), ), Divider(thickness: 1), ]);

rivella50 commented 2 years ago

Same here, still doesn't work. Signature seems to be open to the right and bottom side, even when i set a width value. Screenshot 2022-05-23 at 07 23 53

                child: SingleChildScrollView(
                  child: Column(
                    children: [
                      const SizedBox(
                        height: 30,
                      ),
                      Signature(
                        controller: _companySignatureController,
                        height: 150,
                        backgroundColor: Colors.grey,
                      ),

Is there a hack to fix this on our side or a package version to go down in order that this works again meanwhile?

maddionatoplus commented 2 years ago

Same as me, I am drawing everywhere. Really a big problem for me. What can I do?

cfsbhawkins commented 2 years ago

The workaround I did was, I made it a full screen landscape view problem solved for my use case.

rivella50 commented 2 years ago

Not possible for me since i have to offer 2 signature areas in my view. If the developer is not able to react soon i will have to find another package or implement this feature by myself.

rivella50 commented 2 years ago

My hack solution is the following: I adjusted function SignatureState::_addPoint like this:

final myWidth = widget.width ?? screenSize!.width;
final myHeight = widget.height ?? screenSize!.height;

//SAVE POINT ONLY IF IT IS IN THE SPECIFIED BOUNDARIES
if (o.dx > 0 && o.dx < myWidth &&
    o.dy > 0 && o.dy < myHeight) {

And when defining a height and width explicitely or implicitely (e.g. by using a LayoutBuilder around Signature) it seems to work for me. The problem with the original code seems to be that it doesn't take into account the optionally defined width and height parameters, which both are <= their screenSize pendants, and if they are smaller drawing across the right and bottom borders is possible.

alex-cp360 commented 2 years ago

I have solved this issue by using ClipRect as the parent for the Signature widget Screenshot 2022-06-14 at 12 37 17 PM .