cropImage method

Future<String?> cropImage()

Implementation

Future<String?> cropImage() async {
  final image = await cropController.onCropImage();
  if (image != null) {
    io.Directory tempDir = await getTemporaryDirectory();
    String tempPath = tempDir.path;
    final filePath =
        '$tempPath/${DateTime.now().toIso8601String()}-cropped-image.png';
    final file = io.File(filePath);
    final byteData = image.bytes.buffer.asUint8List();
    file.createSync();
    await file.writeAsBytes(byteData.toList());
    return file.path;
  }
  return null;
}