holding_gesture 1.0.0-dev copy "holding_gesture: ^1.0.0-dev" to clipboard
holding_gesture: ^1.0.0-dev copied to clipboard

outdated

A customized GestureDetector that acts on holding a determined Widget.

holding_gesture #

A customized GestureDetector that acts on holding a determined Widget.

Getting Started #

import 'package:holding_gesture/holding_gesture.dart';

After importing, all you have to do is use HoldDetector the same way you already used GestureDetector! As it is on the documentation, its onTap override won't work when using a child that has onPressed or a similar callback, so you should pass the single tap behaviour to that.

@override
Widget build(BuildContext context) {
  return MaterialApp(
    home: Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: Text(
                'You have pushed (or held) the button this many times:',
                textAlign: TextAlign.center,
              ),
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: HoldDetector(
        onHold: _incrementCounter,
        holdTimeout: Duration(milliseconds: 200),
        enableHapticFeedback: true,
        child: FloatingActionButton(
          child: Icon(Icons.add),
          onPressed: _incrementCounter,
      ),
    ),
  ),
);

The main example, above and in example/, is the same as the default Flutter app, with the adition of a haptic feedback to each tick and the ability to hold the button to keep adding to the counter.

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

47
likes
0
pub points
92%
popularity

Publisher

verified publishergildaswise.com

A customized GestureDetector that acts on holding a determined Widget.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on holding_gesture