I'm making a watermark image using flutter and I need to convert Future to Uint8List.
This is the code where the problem happens.
child: Image.memory(putWatermarkOnImage(asset))
The child is in the Container widget and the result of the putWatermarkOnImage function has to be Uint8List type not a future type.
Future<Uint8List> putWatermarkOnImage(asset) async {
final assetFile = await asset.file;
var imageBytes = await assetFile!.readAsBytes();
ByteData watermarkImgByteData = await rootBundle.load('assets/images/ournow_logo.png');
Uint8List watermarkImgBytes = watermarkImgByteData.buffer.asUint8List();
Uint8List imageUint8List = Uint8List.fromList(imageBytes);
Uint8List watermarkedImg = await ImageWatermark.addImageWatermark(
originalImageBytes: imageUint8List,
waterkmarkImageBytes: watermarkImgBytes,
imgHeight: 200,
imgWidth: 200,
dstY: 400,
dstX: 400);
return watermarkedImg;
}
How can I solve this problem?