Closed madsane29 closed 2 years ago
I believe I fixed the problem. Pull Request here:
its fixed or not? i have the same issue
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?
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.
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,
),
);
}
}
I don't know why it is not working for you. At me it is fine...
@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
PR is merged and published in 5.1.0
Thanks!
It is not fixed. You still can draw outside of the boundaries to the right and to the bottom.