launchLinkExternal method

Future<void> launchLinkExternal(
  1. String url,
  2. {String? title,
  3. String? description,
  4. String? buttonText,
  5. String? closeButtonText,
  6. Function? extraOnConfirmFunction}
)

Implementation

Future<void> launchLinkExternal(
  String url, {
  String? title,
  String? description,
  String? buttonText,
  String? closeButtonText,
  Function? extraOnConfirmFunction,
}) async {
  AlertResponse exit = await (_dialogService.showDialog(
    BasicDialog(
        title: title ?? "You're about to leave",
        description: description ??
            "This link will take you out of the app. Are you sure you want to go?",
        buttons: <DialogButton>[
          DialogButton(
            text: buttonText ?? "Let's go",
            response: true,
          ),
          DialogButton(
            text: closeButtonText ?? "Close",
            response: false,
            style: DarkButtonStyle.Secondary,
          ),
        ]),
  ) as Future<AlertResponse>);

  if (exit.response) {
    if (extraOnConfirmFunction != null) {
      extraOnConfirmFunction();
    }
    await urlLauncher.openUrl(Uri.parse(url));
  }
}