mirror of
https://github.com/austinried/subtracks.git
synced 2026-02-10 06:52:43 +01:00
add snackbar method for errors
test (ping) server before saving source display error message when saving source
This commit is contained in:
@@ -12,6 +12,7 @@ import '../../log.dart';
|
||||
import '../../models/settings.dart';
|
||||
import '../../services/settings_service.dart';
|
||||
import '../items.dart';
|
||||
import '../snackbars.dart';
|
||||
|
||||
class SourcePage extends HookConsumerWidget {
|
||||
final int? id;
|
||||
@@ -164,6 +165,7 @@ class SourcePage extends HookConsumerWidget {
|
||||
}
|
||||
} catch (e, st) {
|
||||
// TOOD: toast the error or whatever
|
||||
showErrorSnackbar(context, e.toString());
|
||||
log.severe('Saving source', e, st);
|
||||
error = true;
|
||||
} finally {
|
||||
|
||||
14
lib/app/snackbars.dart
Normal file
14
lib/app/snackbars.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void showErrorSnackbar(BuildContext context, String message) {
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(message, style: TextStyle(color: colors.onErrorContainer)),
|
||||
backgroundColor: colors.errorContainer,
|
||||
showCloseIcon: true,
|
||||
closeIconColor: colors.onErrorContainer,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 10),
|
||||
));
|
||||
}
|
||||
Reference in New Issue
Block a user