Fix local dev config and ALOTTTT OFF FLUTTER, im tired boss..
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
Future<T?> ignoreInitFailure<T>(
|
||||
Future<T> Function() action, {
|
||||
required String label,
|
||||
}) async {
|
||||
try {
|
||||
return await action();
|
||||
} catch (error) {
|
||||
debugPrint('$label skipped: $error');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'dart:async';
|
||||
|
||||
Future<T?> guarded<T>(
|
||||
Future<T> Function() action, {
|
||||
void Function(Object error)? onError,
|
||||
void Function()? onTimeout,
|
||||
}) async {
|
||||
try {
|
||||
return await action();
|
||||
} on TimeoutException catch (error) {
|
||||
onTimeout?.call();
|
||||
onError?.call(error);
|
||||
return null;
|
||||
} catch (error) {
|
||||
onError?.call(error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user