sensitive_content_analysis 0.0.3 sensitive_content_analysis: ^0.0.3 copied to clipboard
Flutter package for interacting with Apple's Sensitive Content Analysis.
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:sensitive_content_analysis/sensitive_content_analysis_platform.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
Future<void> sendMessageWithImage() async {
try {
final ImagePicker picker = ImagePicker();
// Pick an image.
final XFile? image = await picker.pickImage(source: ImageSource.gallery);
if (image != null) {
Uint8List imageData = await image.readAsBytes();
// Analyze the image for sensitive content.
bool? isSensitive = await SensitiveContentAnalysisPlatform.instance
.analyzeImage(imageData);
print("SENS: $isSensitive");
}
} catch (e) {
debugPrint(e.toString());
}
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: Center(
child: ElevatedButton(
onPressed: () => sendMessageWithImage(),
child: Text("IMAGE"),
),
),
),
);
}
}