简体   繁体   中英

Download image in mobile in flutter web

I created a flutter web app that creates an image and generates the base64 data. so I used AnchorElement in the HTML package to download the image to the client, it works on mac and windows but when I want to be downloaded on mobile nothing happen at all.

any clue?

code:

Future<void> downloadImage(Uint8List data8) async {
    try {
      final base64data = base64Encode(data8);
      final a = html.AnchorElement(href: 'data:image/jpeg;base64,$base64data');
      a.download = 'image.jpg';

      a.click();
      a.remove();
    } catch (e) {
      print(e);
    }
  }

In general mobile apps need rights to access certain resource, eg access the.network.

Search for entitlement on iOS like this and manifest on Android.

You need to set these rights in the iOS or Android project. Without this rights, access gets simply denied.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM