Small fixes
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pweb/utils/error/handler.dart';
|
||||
@@ -41,6 +39,26 @@ Future<void> notifyUserOfErrorX({
|
||||
);
|
||||
}
|
||||
|
||||
void showErrorSnackBar({
|
||||
required ScaffoldMessengerState scaffoldMessenger,
|
||||
required String errorSituation,
|
||||
required Object exception,
|
||||
required AppLocalizations appLocalizations,
|
||||
int delaySeconds = 3,
|
||||
}) {
|
||||
final localizedError = ErrorHandler.handleErrorLocs(appLocalizations, exception);
|
||||
final technicalDetails = exception.toString();
|
||||
final snackBar = _buildMainErrorSnackBar(
|
||||
errorSituation: errorSituation,
|
||||
localizedError: localizedError,
|
||||
technicalDetails: technicalDetails,
|
||||
loc: appLocalizations,
|
||||
scaffoldMessenger: scaffoldMessenger,
|
||||
delaySeconds: delaySeconds,
|
||||
);
|
||||
scaffoldMessenger.showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
Future<void> notifyUserOfError({
|
||||
required BuildContext context,
|
||||
required String errorSituation,
|
||||
@@ -88,26 +106,14 @@ Future<void> postNotifyUserOfError({
|
||||
required Object exception,
|
||||
required AppLocalizations appLocalizations,
|
||||
int delaySeconds = 3,
|
||||
}) {
|
||||
final completer = Completer<void>();
|
||||
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
if (!context.mounted) {
|
||||
completer.complete();
|
||||
return;
|
||||
}
|
||||
await notifyUserOfErrorX(
|
||||
}) =>
|
||||
notifyUserOfErrorX(
|
||||
context: context,
|
||||
errorSituation: errorSituation,
|
||||
exception: exception,
|
||||
appLocalizations: appLocalizations,
|
||||
delaySeconds: delaySeconds,
|
||||
);
|
||||
completer.complete();
|
||||
});
|
||||
|
||||
return completer.future;
|
||||
}
|
||||
|
||||
Future<void> postNotifyUserOfErrorX({
|
||||
required BuildContext context,
|
||||
|
||||
@@ -10,7 +10,6 @@ Future<void> notifyUserX(
|
||||
String message, {
|
||||
int delaySeconds = 3,
|
||||
}) async {
|
||||
if (!context.mounted) return;
|
||||
final scaffoldMessenger = ScaffoldMessenger.maybeOf(context);
|
||||
if (scaffoldMessenger != null) {
|
||||
scaffoldMessenger.showSnackBar(
|
||||
|
||||
Reference in New Issue
Block a user