赞
踩
- // 保存到相册的UTil
- import 'package:dio/dio.dart';
- import 'package:flutter/services.dart';
- import 'package:image_gallery_saver/image_gallery_saver.dart';
- import 'package:permission_handler/permission_handler.dart';
- import 'package:yl_etf/utils/util.dart';
-
- class SaveToAlbumUtil {
- static void saveNetworkImage(String imageUrl) async {
- //检查是否有存储权限
- var status = await Permission.storage.status;
- if (status.isGranted) {
- var response = await Dio()
- .get(imageUrl, options: Options(responseType: ResponseType.bytes));
- final result = await ImageGallerySaver.saveImage(
- Uint8List.fromList(response.data),
- quality: 60,
- name: "hello");
- BLDUtil.toast('保存成功');
- } else {
- status = await Permission.storage.request();
- }
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。