onSchemaHandlerTap function

Future<void> onSchemaHandlerTap({
  1. required String url,
  2. void onException(
    1. String
    )?,
})

Implementation

Future<void> onSchemaHandlerTap({
  required String url,
  void Function(String)? onException,
}) async {
  LaunchMode mode = LaunchMode.externalApplication;
  if (url.contains("tg:") || await canLaunchUrl(Uri.parse(url))) {
    try {
      await launchUrl(
        Uri.parse(url),
        mode: mode,
      );
    } catch (e) {
      if (onException != null) {
        onException('Could not launch the URL: $url');
      } else {
        log('Could not launch the URL: $url');
      }
    }
  }
}