AiSensitiveContentDetector constructor
AiSensitiveContentDetector({})
Creates an instance of AiSensitiveContentDetector.
apiKey is required to authenticate with Google's Gemini API.
Optional parameters allow customization of generation behavior:
model, temperature, topP, topK, maxOutputTokens.
Implementation
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,
}) {
_geminiModel = GenerativeModel(
model: model,
apiKey: apiKey,
generationConfig: GenerationConfig(
temperature: temperature,
topP: topP,
topK: topK,
maxOutputTokens: maxOutputTokens,
responseMimeType: "application/json",
responseSchema: Schema.object(
properties: {
'imageClassification': Schema.string(nullable: false),
'textClassification': Schema.string(nullable: false),
'isSensitive': Schema.boolean(nullable: false),
},
requiredProperties: [
'imageClassification',
'textClassification',
'isSensitive',
],
),
),
safetySettings: [
SafetySetting(HarmCategory.sexuallyExplicit, HarmBlockThreshold.none),
SafetySetting(HarmCategory.dangerousContent, HarmBlockThreshold.none),
SafetySetting(HarmCategory.harassment, HarmBlockThreshold.none),
SafetySetting(HarmCategory.hateSpeech, HarmBlockThreshold.none),
],
);
}