withTimeout method
Completes with fallback if this future does not resolve within timeout.
Returns null as fallback if not specified.
fetchData().withTimeout(Duration(seconds: 5), fallback: defaultValue)
Implementation
Future<T?> withTimeout(Duration timeout, {T? fallback}) async {
try {
return await this.timeout(timeout);
} on Object {
return fallback;
}
}