touchable 0.1.5 copy "touchable: ^0.1.5" to clipboard
touchable: ^0.1.5 copied to clipboard

outdated

Flutter library to add various gesture callbacks to each Shape you draw on your canvas in your CustomPainterFlutter library to add various gesture callbacks to each Shape you draw on your canvas in yo [...]

example/example.dart

import 'package:flutter/material.dart';
import 'package:touchable/touchable.dart';

class MyExampleWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    FocusScope.of(context).nextFocus();
    return Flexible(
      child: FractionallySizedBox(
          widthFactor: 1,
          heightFactor: 1,
          child: CanvasTouchDetector(
            builder: (context) {
              return CustomPaint(
                painter: MyPainter(context),
              );
            },
          )),
    );
  }
}

class MyPainter extends CustomPainter {
  final BuildContext context;
  MyPainter(this.context); // context from CanvasTouchDetector

  @override
  void paint(Canvas canvas, Size size) {
    var myCanvas = TouchyCanvas(context, canvas);

    myCanvas.drawCircle(Offset(10, 10), 60, Paint()..color = Colors.orange,
        onTapDown: (tapdetail) {
      print('orange Circle touched');
    }, onPanDown: (tapdetail) {
      print('orange circle swiped');
    });

    myCanvas.drawLine(
        Offset(0, 0),
        Offset(size.width - 100, size.height - 100),
        Paint()
          ..color = Colors.black
          ..strokeWidth = 50, onPanUpdate: (detail) {
      print(
          'Black line Swiped'); //do cooler things here. Probably change app state or animate
    });
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) {
    return false;
  }
}
232
likes
0
points
9.25k
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter library to add various gesture callbacks to each Shape you draw on your canvas in your CustomPainterFlutter library to add various gesture callbacks to each Shape you draw on your canvas in your CustomPainter

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on touchable