downloadLink static method

bool downloadLink(
  1. String url, {
  2. String? name,
})

Implementation

static bool downloadLink(String url, {String? name}) {
  Document htmlDocument = document;
  HTMLAnchorElement anchor =
      htmlDocument.createElement('a') as HTMLAnchorElement;
  anchor.href = url;
  if (name != null && name.isNotEmpty) {
    anchor.download = name;
  }
  anchor.rel = 'noopener';
  document.body!.add(anchor);
  anchor.click();
  anchor.remove();
  return true;
}