analyseIsSensitiveContentFromImage method
Accepts a ui.Image, converts it to bytes, and delegates to analyseIsSensitiveContent.
Useful when working with Canvas, RepaintBoundary, or Flutter rendering APIs.
Implementation
@override
Future<AiClassificationResponse?> analyseIsSensitiveContentFromImage({
required ui.Image image,
String text = '',
}) async {
try {
// Convert ui.Image to Uint8List
final byteData = await image.toByteData(format: ui.ImageByteFormat.png);
if (byteData == null) return null;
final Uint8List imageBytes = byteData.buffer.asUint8List();
// Call the existing function with converted bytes
return await analyseIsSensitiveContent(
receiptImageBytes: imageBytes,
text: text,
);
} catch (e) {
_logger.e('Error while converting to bytes: $e');
return null;
}
}