Unable to process any UploadedFile parameter in Custom Action. Not allowed to save.

Custom Code

I am trying to implement a custom action in my app, but I keep running into this error when trying to save. The most frustrating thing is that if I click "Save anyway", the action does not save, meaning my work is getting constantly deleted.

At first this was a problem with the return parameter, however I switched to an action parameter instead, and I was then getting the warning for my input parameter.

Here is my code:

import 'dart:io';
import 'package:image_cropper/image_cropper.dart';
import 'package:path_provider/path_provider.dart';

Future<Uint8List?> cropSquareImage(Uint8List? imageToCrop) async {
  // A null check for the input bytes
  if (imageToCrop == null) {
    return null;
  }

  // image_cropper works with files, so we need to write the bytes to a temporary file
  final tempDir = await getTemporaryDirectory();
  final tempFile = await new File('${tempDir.path}/image_to_crop.jpg')
      .writeAsBytes(imageToCrop);

  final croppedFile = await ImageCropper().cropImage(
    sourcePath: tempFile.path,
    maxWidth: 500, // <-- ADDED: Sets the maximum width of the output file
    maxHeight: 500, // <-- ADDED: Sets the maximum height of the output file
    aspectRatio: CropAspectRatio(
        ratioX: 1.0, ratioY: 1.0), // Enforces a square aspect ratio
    uiSettings: [
      AndroidUiSettings(
          toolbarTitle: 'Crop Image',
          toolbarColor: Colors.deepOrange,
          toolbarWidgetColor: Colors.white,
          initAspectRatio: CropAspectRatioPreset.square,
          lockAspectRatio: true),
      IOSUiSettings(
        title: 'Crop Image',
        aspectRatioLockEnabled: true,
        resetAspectRatioEnabled: false,
        aspectRatioPickerButtonHidden: true,
      ),
    ],
  );

  // If the user cancels the crop, the result is null
  if (croppedFile == null) {
    return null;
  }

  // Read the cropped image file back into bytes and return it
  return await croppedFile.readAsBytes();
}
What have you tried so far?
  • Changing output from return parameter to custom action.

Did you check FlutterFlow's Documentation for this topic?
Yes
2
2 replies