4Q-s-r-o / signature

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

It is possible to draw outside of boundaries #61

Closed madsane29 closed 2 years ago

madsane29 commented 2 years ago

It is not fixed. You still can draw outside of the boundaries to the right and to the bottom.

madsane29 commented 2 years ago

I believe I fixed the problem. Pull Request here:

https://github.com/4Q-s-r-o/signature/pull/62

crpo10 commented 2 years ago

its fixed or not? i have the same issue

NitinSojitra commented 2 years ago

I have the same issue. User can draw right and bottom outside of signature pad. Can you fix it or any solution for this issue?

madsane29 commented 2 years ago

You can try out my fix if you add the following to your pubspec.yaml:

  signature:
    git:
      url: https://github.com/madsane29/signature
      ref: fix-draw-outside-of-canvas

Or if you download the modified signature.dart and add it to your project.

madsane29 commented 2 years ago

Here is a small code to try it out:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:signature/signature.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Signature Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final SignatureController _controller = SignatureController();

  @override
  void initState() {
    super.initState();
    SystemChrome.setPreferredOrientations([DeviceOrientation.landscapeLeft]);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Signature(
          controller: _controller,
          width: MediaQuery.of(context).size.width * 0.7,
          height: MediaQuery.of(context).size.height * 0.7,
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: _controller.clear,
      ),
    );
  }
}
madsane29 commented 2 years ago

I don't know why it is not working for you. At me it is fine...

image

NitinSojitra commented 2 years ago

@madsane29 Sorry bro, I wasted your time. I used MediaQuery in dialog box and I forget about full width. When I put it in layout builder and set width using constraints.maxWidth. It works.

Thank you so much

MartinHlavna commented 2 years ago

PR is merged and published in 5.1.0

MartinHlavna commented 2 years ago

Thanks!