holding_gesture 0.0.2 copy "holding_gesture: ^0.0.2" to clipboard
holding_gesture: ^0.0.2 copied to clipboard

outdated

A customized GestureDetector that acts on holding a determined Widget.

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  int _counter = 0;

  void _incrementCounter() {
    if (mounted) {
      setState(() {
        _counter += 1;
      });
    }
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('holding_gesture'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Text(
                'You have pushed (or held) the button this many times:',
              ),
              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,
          ),
        ),
      ),
    );
  }
}
47
likes
0
pub points
94%
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