CarnegieTechnologies / gallery_saver

Flutter plugin that saves images and videos to devices gallery
Apache License 2.0
157 stars 316 forks source link

It is not saved as transparent on the iPhone #217

Open hichkas9 opened 8 months ago

hichkas9 commented 8 months ago

hi.

Recently, photos on the iPhone are getting a white background? What problem has occurred?

The codes for converting a widget to an image are as follows:

   RenderRepaintBoundary? boundary =
          key1.currentContext?.findRenderObject() as RenderRepaintBoundary?;
      ui.Image image = await boundary!.toImage(pixelRatio: 3.0);
      ByteData? byteData =
          await image.toByteData(format: ui.ImageByteFormat.png);
      pngBytes = byteData!.buffer.asUint8List();
      imageInMemory = pngBytes;
      inside.value = false;

      final String dir;
      if (Platform.isAndroid) {
        dir = (await getExternalStorageDirectory())?.path ?? "";
      } else {
        dir = (await getApplicationDocumentsDirectory()).path;
      }
      final String fileName = "${DateTime.now().millisecondsSinceEpoch}";
      final String fullPath = '$dir/$fileName.png';
      File capturedFile = File(fullPath);
      await capturedFile.writeAsBytes(pngBytes!);