-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug report] Unintended Drawing Recorded During Pinch Gestures #66
Comments
After trying various approaches, I confirmed that unintended drawing is recorded when only onPointerDown is called and onPointerMove or onPointerUp are not called. This has resolved the issue, so there is no urgent need to address it immediately; however, I would appreciate it if you could fix this issue when you have time. import 'package:flutter/material.dart';
import 'package:flutter_drawing_board/flutter_drawing_board.dart';
import 'package:flutter_drawing_board/paint_contents.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Drawing Board Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final DrawingController _drawingController = DrawingController();
void _listener() {
print('listener');
if (_isPointerDown) {
List<PaintContent> contents = List.of(_drawingController.getHistory);
contents.removeLast();
_drawingController.clear();
_drawingController.addContents(contents);
print('listener: history changed');
}
print(_drawingController.getHistory);
}
@override
void initState() {
super.initState();
_drawingController.addListener(_listener);
}
bool _isPointerDown = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Drawing Board Example'),
),
body: LayoutBuilder(
builder: (context, constraints) {
return DrawingBoard(
controller: _drawingController,
background: Container(
width: constraints.maxWidth,
height: constraints.maxHeight,
color: Colors.white,
),
showDefaultActions: true,
showDefaultTools: true,
onPointerDown: (details) {
_isPointerDown = true;
print('onPointerDown');
print(_drawingController.getHistory);
},
onPointerMove: (details) {
_isPointerDown = false;
print('onPointerMove');
print(_drawingController.getHistory);
},
onPointerUp: (details) {
_isPointerDown = false;
print('onPointerUp');
print(_drawingController.getHistory);
},
onInteractionStart: (details) {
print('onInteractionStart');
print(_drawingController.getHistory);
},
onInteractionEnd: (details) {
print('onInteractionEnd');
print(_drawingController.getHistory);
},
);
},
),
);
}
}
|
Fixed at 0.9.7 |
Thank you for your response and update. After upgrading from version 0.9.5 to 0.9.8, the pinch gesture issue on the simulator has been resolved. However, on a physical device (Pixel 8a), a dot appears at the start of the pinch gesture, as shown in the attached video. In version 0.9.5, this dot was not displayed. screen-20250324-094756.mp4import 'package:flutter/material.dart';
import 'package:flutter_drawing_board/flutter_drawing_board.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Drawing Board Example',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final DrawingController _drawingController = DrawingController();
void _listener() {
print('listener');
print(_drawingController.getHistory);
}
@override
void initState() {
super.initState();
_drawingController.addListener(_listener);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Drawing Board Example'),
),
body: LayoutBuilder(
builder: (context, constraints) {
return DrawingBoard(
controller: _drawingController,
background: Container(
width: constraints.maxWidth,
height: constraints.maxHeight,
color: Colors.white,
),
showDefaultActions: true,
showDefaultTools: true,
onPointerDown: (details) {
print('onPointerDown');
print(_drawingController.getHistory);
},
onPointerMove: (details) {
print('onPointerMove');
print(_drawingController.getHistory);
},
onPointerUp: (details) {
print('onPointerUp');
print(_drawingController.getHistory);
},
onInteractionStart: (details) {
print('onInteractionStart');
print(_drawingController.getHistory);
},
onInteractionEnd: (details) {
print('onInteractionEnd');
print(_drawingController.getHistory);
},
);
},
),
);
}
}
|
Version
0.9.5
Platforms
Android, iOS
Device Model
Pixel 8a (Android 15), iPhone 16 (iOS 18.2, iOS Simulator)
flutter info
How to reproduce?
Thank you for creating this wonderful package.
When performing pinch gestures (such as pinch-to-zoom) while using the
flutter_drawing_board
, unintended drawing is recorded.I attempted to call
_drawingBoardController.cancelDraw();
within onInteractionStart, onInteractionUpdate, and onInteractionEnd, but the issue persists.The following log was recorded when running the example code and repeatedly performing pinch in/out gestures.
Although the pinch gesture does not always record drawing, it does so with a high probability.
As a result, even if nothing appears to be drawn, the undo button becomes enabled.
The same issue can be observed in the demo provided in the Readme.
I would appreciate any guidance on how to resolve this problem.
Logs
Example code (optional)
Contact
No response
The text was updated successfully, but these errors were encountered: