2024-03-10 18:00:46 +08:00
|
|
|
import 'package:fluent_ui/fluent_ui.dart';
|
|
|
|
import 'package:starcitizen_doctor/common/utils/base_utils.dart';
|
2024-03-10 16:26:04 +08:00
|
|
|
import 'package:starcitizen_doctor/common/utils/log.dart';
|
|
|
|
|
|
|
|
extension AsyncError on Future {
|
2024-03-10 18:00:46 +08:00
|
|
|
Future<T?> unwrap<T>({BuildContext? context}) async {
|
2024-03-10 16:26:04 +08:00
|
|
|
try {
|
|
|
|
return await this;
|
|
|
|
} catch (e) {
|
|
|
|
dPrint("unwrap error:$e");
|
2024-03-12 22:08:46 +08:00
|
|
|
if (context != null && context.mounted) {
|
2024-03-17 16:54:09 +08:00
|
|
|
showToast(context, S.current.app_common_error_info(e.toString()));
|
2024-03-10 18:00:46 +08:00
|
|
|
}
|
2024-03-10 16:26:04 +08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|