Returns a Future
that resolves after Duration
and optionally calls before
and after
the Duration.
Source
Future timeout(Duration duration, {Function before, Function after}) async { if ( before != null ) before(); await wait(duration); if ( after != null ) after(); }