nsgFutureProgressAndException function
Future
nsgFutureProgressAndException({
- required Future<
void> func(), - String? text,
- BuildContext? context,
- bool showProgress = true,
- int? delay,
Вызов Future функции с прогресс индикатором и проверкой на ошибки
Implementation
Future nsgFutureProgressAndException({required Future<void> Function() func, String? text, BuildContext? context, bool showProgress = true, int? delay}) async {
var progress = NsgProgressDialog(textDialog: text ?? '', context: context, delay: delay);
try {
if (showProgress) {
progress.show();
}
await func();
if (showProgress) {
progress.hide();
await Future.delayed(const Duration(milliseconds: 100));
}
} catch (ex) {
if (showProgress) {
progress.hide();
await Future.delayed(const Duration(milliseconds: 100));
}
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (ex is Exception) {
await NsgErrorWidget.showError(ex);
} else {
await NsgErrorWidget.showErrorByString(ex.toString());
}
});
rethrow;
}
}