Skip to content
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

Click on the failure #32

Open
jahnli opened this issue Sep 1, 2021 · 1 comment
Open

Click on the failure #32

jahnli opened this issue Sep 1, 2021 · 1 comment

Comments

@jahnli
Copy link

jahnli commented Sep 1, 2021

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;
}
}

@jahnli
Copy link
Author

jahnli commented Sep 1, 2021

When I run demo, it doesn't respond onTapDown onLongPressStart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant