encapsulated snackbar call on error
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:provider/provider.dart';
|
||||
import '../model/bookmark.dart';
|
||||
import '../model/maps_link_metadata.dart';
|
||||
import '../service/bookmarks_provider.dart';
|
||||
import '../service/notifying.dart';
|
||||
import '../service/shared_link_provider.dart';
|
||||
import '../service/storage.dart';
|
||||
import '../service/url_launcher.dart';
|
||||
@@ -62,8 +63,8 @@ class _CollectionPageState extends State<CollectionPage> {
|
||||
return ListTile(
|
||||
title: Text(bookmark.name),
|
||||
onTap: () => launchUrlFromString(bookmark.link).then((errorCode) {
|
||||
if (context.mounted && errorCode != UrlLaunchErrorCode.none) {
|
||||
return showUrlError(context, errorCode);
|
||||
if (context.mounted) {
|
||||
return Notifying.showUrlErrorSnackbar(context, errorCode);
|
||||
}
|
||||
}),
|
||||
onLongPress: () => editBookmark(bookmark),
|
||||
@@ -109,16 +110,4 @@ class _CollectionPageState extends State<CollectionPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void showUrlError(BuildContext context, UrlLaunchErrorCode errorCode) {
|
||||
String errorText = '';
|
||||
if (errorCode == UrlLaunchErrorCode.couldNotLaunch) {
|
||||
errorText = 'Could not launch Url';
|
||||
} else {
|
||||
errorText = 'Invalid Url';
|
||||
}
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(errorText)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user