AiSensitiveContentDetector class

A service class that uses the Google Generative AI Gemini model to classify text and/or image input as sensitive or not.

This class supports multiple input types (raw bytes, ui.Image, ImageProvider) and can be easily extended or configured for fine-tuned sensitivity detection.

Typical usage:

final classifier = AiTextImageClassifier(apiKey: 'your-key');
final result = await classifier.analyseIsSensitiveContent(text: '...');
Implemented types

Constructors

AiSensitiveContentDetector({required String apiKey, String model = 'gemini-2.0-flash-lite', double temperature = 0.1, double topP = 0.95, int topK = 64, int maxOutputTokens = 8192})
Creates an instance of AiSensitiveContentDetector.

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
textPrompt String
Prompt used to guide the Gemini model in classification tasks.
final

Methods

analyseIsSensitiveContent({Uint8List? receiptImageBytes, String text = ''}) Future
Classifies the content from both optional receiptImageBytes and text for sensitive categories using Gemini.
override
analyseIsSensitiveContentFromImage({required Image image, String text = ''}) Future<AiClassificationResponse?>
Accepts a ui.Image, converts it to bytes, and delegates to analyseIsSensitiveContent.
override
analyseIsSensitiveContentFromImageProvider({required ImageProvider<Object> imageProvider, String text = ''}) Future<AiClassificationResponse?>
Accepts an ImageProvider, resolves it into an image, converts it to bytes, and passes it to analyseIsSensitiveContent.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited