saveImage method

void saveImage()

Save the edited-image to widget.savePath or getTemporaryDirectory().

Implementation

void saveImage() {
  _panelController.takeShot.value = true;
  screenshotController.capture(pixelRatio: 1.0).then((value) async {
    final paths = widget.savePath ?? await getTemporaryDirectory();
    final file = await File('${paths.path}/' + DateTime.now().toString() + '.jpg').create();
    file.writeAsBytes(value ?? []);
    decodeImg().then((value) {
      if (value == null) {
        Navigator.pop(context);
      } else {
        Navigator.pop(context, EditorImageResult(value.width, value.height, file));
      }
    }).catchError((e) {
      Navigator.pop(context);
    });
  });
}