cropImages method

Future<List<List<int>>?> cropImages(
  1. BuildContext context, {
  2. required List<List<int>> imageList,
  3. double? ratio = 1 / 1,
  4. bool isCircle = false,
  5. bool isFree = true,
  6. Color backColor = Colors.white,
})

Implementation

Future<List<List<int>>?> cropImages(
  BuildContext context, {
  required List<List<int>> imageList,
  double? ratio = 1 / 1,
  bool isCircle = false,
  bool isFree = true,
  Color backColor = Colors.white,
}) async {
  List<Uint8List> imageDataList = [];
  for (var el in imageList) {
    final mainImage = imagedit.decodeImage(Uint8List.fromList(el));
    final background = imagedit.Image(width: mainImage!.width + 500, height: mainImage.height + 500);

    for (var pixel in background) {
      pixel.setRgba(backColor.r, backColor.g, backColor.b, backColor.a);
    }

    imagedit.Image mergeImage = imagedit.compositeImage(background, mainImage, center: true);

    //imageDataList.add(Uint8List.fromList(el));
    imageDataList.add(imagedit.encodePng(mergeImage));
  }
  Future<List<Uint8List>?> imdd =
      Navigator.push(
        context,
        CupertinoPageRoute(
          builder: ((context) => NsgCropPage(imageDataList: imageDataList, aspectRatio: ratio, isFree: isFree, isCircle: isCircle)),
        ),
      ).then((value) {
        return value;
      });
  return await imdd;
}