fbmobile/lib/core/services/link_service.dart

24 lines
710 B
Dart
Raw Normal View History

2021-02-02 14:33:23 +00:00
import 'package:flutter_translate/global.dart';
import 'package:logger/logger.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../core/services/dialog_service.dart';
import '../../core/util/logger.dart';
import '../../locator.dart';
class LinkService {
final Logger _logger = getLogger();
final DialogService _dialogService = locator<DialogService>();
Future open(String link) async {
if (await canLaunch(link)) {
await launch(link);
} else {
_logger.e('Could not launch link $link');
_dialogService.showDialog(
title: translate('link.dialog.title'),
description: translate('link.dialog.description', args: {'link': link}));
}
}
}