saveUiImage static method

void saveUiImage(
  1. GlobalKey<State<StatefulWidget>> key
)

Implementation

static void saveUiImage(GlobalKey key) async {
  LoadingUtils.loading();
  ByteData? sourceByteData = await _capturePngToByteData(key);
  Uint8List sourceBytes = sourceByteData!.buffer.asUint8List();
  final result = await ImageGallerySaver.saveImage(
    sourceBytes,
    quality: 100,
  ); //这个是核心的保存图片的插件
  if (result['isSuccess']) {
    ToastUtils.toast(msg: "保存成功");
  } else {
    ToastUtils.toast(msg: "保存失败");
  }
  LoadingUtils.dismiss();
}