holding_gesture 0.0.3 copy "holding_gesture: ^0.0.3" to clipboard
holding_gesture: ^0.0.3 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
40
pub points
94%
popularity

Publisher

verified publishergildaswise.com

A customized GestureDetector that acts on holding a determined Widget.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on holding_gesture