DelayBlock class
A helper to ensure a block of asynchronous code takes a minimum amount of time to complete.
This is useful for preventing jarring UI flashes when an operation finishes too quickly (e.g., a loading indicator that appears and disappears instantly).
Example:
final delay = DelayBlock(Duration(milliseconds: 500));
await veryFastApiCall();
await delay.finish(); // This will wait for the remaining time.
Constructors
- DelayBlock(Duration duration, [bool startNow = true])
-
Default constructor
durationof delay block.startNowimmediately in constructor.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
finish(
) → Future< void> - Awaits the completion of the delay block.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → void - Starts the timer. This should be called before the async operation begins.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited