Files
maps_bookmarks/lib/service/notifying.dart
2026-01-21 16:31:43 +01:00

39 lines
958 B
Dart

import 'package:flutter/material.dart';
import 'url_launcher.dart' show UrlLaunchErrorCode;
class Notifying {
static void showSnackbar(
BuildContext context, {
required String text,
bool isError = false,
}) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
backgroundColor: Theme.of(context).colorScheme.error,
content: Text(
text,
style: isError
? TextStyle(color: Theme.of(context).colorScheme.onError)
: null,
),
),
);
}
static void showUrlErrorSnackbar(
BuildContext context,
UrlLaunchErrorCode errorCode,
) {
String errorText = '';
if (errorCode == UrlLaunchErrorCode.none) {
return;
} else if (errorCode == UrlLaunchErrorCode.couldNotLaunch) {
errorText = 'Could not launch Url';
} else {
errorText = 'Invalid Url';
}
showSnackbar(context, text: errorText, isError: true);
}
}