feat: enhance error handling; implement copyable SnackBar for user messages across various screens
Test Suite / test (24.15.0) (push) Has been cancelled

This commit is contained in:
Nils-Johan Gynther
2026-05-04 22:10:23 +02:00
parent 2c8d6b69ae
commit 1b1d5d006d
15 changed files with 60 additions and 31 deletions
@@ -52,7 +52,7 @@ class _ConsumeInventoryScreenState
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(mapErrorToUserMessage(e, context))));
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))));
}
} finally {
if (mounted) setState(() => _saving = false);
@@ -139,3 +139,4 @@ class _ConsumeInventoryScreenState
);
}
}
@@ -1,4 +1,4 @@
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
@@ -76,7 +76,7 @@ class _CreateInventoryScreenState
if (mounted) setState(() => _loadingProducts = false);
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(mapErrorToUserMessage(e, context))),
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
);
}
}
@@ -136,7 +136,7 @@ class _CreateInventoryScreenState
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(mapErrorToUserMessage(e, context))));
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))));
}
} finally {
if (mounted) setState(() => _saving = false);
@@ -326,3 +326,4 @@ class _CreateInventoryScreenState
);
}
}
@@ -122,7 +122,7 @@ class _DeleteButton extends ConsumerWidget {
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(mapErrorToUserMessage(e, context))),
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
);
}
}
@@ -159,3 +159,4 @@ class _InfoRow extends StatelessWidget {
);
}
}
@@ -111,7 +111,7 @@ class _InventoryEditScreenState extends ConsumerState<InventoryEditScreen> {
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(mapErrorToUserMessage(e, context))));
.showSnackBar(buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))));
}
} finally {
if (mounted) setState(() => _saving = false);
@@ -297,3 +297,4 @@ class _InventoryEditScreenState extends ConsumerState<InventoryEditScreen> {
);
}
}
@@ -122,7 +122,7 @@ class _SwipeableInventoryTileState
} catch (e) {
if (!mounted) return;
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(mapErrorToUserMessage(e, context))),
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
);
} finally {
if (mounted) setState(() => _acting = false);
@@ -372,7 +372,7 @@ class _DeleteButton extends ConsumerWidget {
ref.invalidate(inventoryProvider);
} catch (e) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(mapErrorToUserMessage(e, context))),
buildCopyableErrorSnackBar(context, mapErrorToUserMessage(e, context))),
);
}
}
@@ -381,3 +381,4 @@ class _DeleteButton extends ConsumerWidget {
);
}
}