HoldDownButton constructor
HoldDownButton({})
Creates a HoldDownButton widget. Great to use when want to execute a function continuously when the button is hold.
- Can be used to make any Widget execute a function periodically when it is hold down.
- Curve/flow towards periodic function execution can be changed. (That is time between each initial function call can be customized.)
- After a
long press
is detected, the onHoldDown function will be called immediately.
Implementation
HoldDownButton({
super.key,
required this.child,
required this.onHoldDown,
this.longWait = const Duration(milliseconds: 600),
this.middleWait = const Duration(milliseconds: 400),
this.minWait = const Duration(milliseconds: 250),
this.holdWait = const Duration(milliseconds: 100),
}) : assert(
(longWait.inMicroseconds >= middleWait.inMicroseconds) &&
(middleWait.inMicroseconds >= minWait.inMicroseconds) &&
(minWait.inMicroseconds >= holdWait.inMicroseconds),
'Initial delays should follow a descending order.',
),
assert(!holdWait.isNegative, 'holdWait cannot be negative.');