I'm making my portfolio website on flutter i want that if someone click on download cv button,it download on his device.CV is place in the assets folder.
downloadFile(url) {
AnchorElement anchorElement =
AnchorElement(href: url);
anchorElement.download = "CV";
anchorElement.click();
}
TextButton(
onPressed: () =>
downloadFile("/assets/files/Hassan_Naveed_CV.pdf"),
child: FittedBox(
child: Row(
children: [
Text(
"Download CV",
style: TextStyle(
color: Theme.of(context)
.textTheme
.bodyText1!
.color),
),
const SizedBox(
width: defaultPadding / 2,
),
const Icon(Icons.download, color: Color(0xFF8B8B8D))
],
),
)),
when i click on the download button ,it shows download failed