We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
import 'dart:math'; import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:touchable/touchable.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key);
@OverRide _MyAppState createState() => _MyAppState(); }
class _MyAppState extends State { @OverRide Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Container( color: Colors.white, //wrap CustomPaint with CanvasTouchDetector child: CanvasTouchDetector( builder: (context) => CustomPaint( painter: MyPaintere(context), ), ), ), )); } }
class MyPaintere extends CustomPainter { final BuildContext context; MyPaintere(this.context); // context from CanvasTouchDetector @OverRide void paint(Canvas canvas, Size size) { //Create and use TouchyCanvas to draw TouchyCanvas touchyCanvas = TouchyCanvas(context, canvas);
var blueCircle = Offset(size.width / 2 + 200, size.height / 2 + 100); var greenCircle = Offset(size.width / 2 + 200, size.height / 2 + 300); touchyCanvas.drawCircle(blueCircle, 60, Paint()..color = Colors.blue, onTapDown: (_) { print('You clicked BLUE circle'); }); touchyCanvas.drawCircle(greenCircle, 30, Paint()..color = Colors.green, onLongPressStart: (_) { print('long pressed on GREEN circle'); });
}
@OverRide bool shouldRepaint(CustomPainter oldDelegate) { return false; } }
The text was updated successfully, but these errors were encountered:
When I run demo, it doesn't respond onTapDown onLongPressStart
Sorry, something went wrong.
No branches or pull requests
import 'dart:math';
import 'dart:ui';
import 'package:flutter/material.dart';
import 'package:touchable/touchable.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@OverRide
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Container(
color: Colors.white,
//wrap CustomPaint with CanvasTouchDetector
child: CanvasTouchDetector(
builder: (context) => CustomPaint(
painter: MyPaintere(context),
),
),
),
));
}
}
class MyPaintere extends CustomPainter {
final BuildContext context;
MyPaintere(this.context); // context from CanvasTouchDetector
@OverRide
void paint(Canvas canvas, Size size) {
//Create and use TouchyCanvas to draw
TouchyCanvas touchyCanvas = TouchyCanvas(context, canvas);
}
@OverRide
bool shouldRepaint(CustomPainter oldDelegate) {
return false;
}
}
The text was updated successfully, but these errors were encountered: