blur_detection 1.0.0 blur_detection: ^1.0.0 copied to clipboard
A Flutter package for detecting blur in images.
import 'dart:io';
import 'package:blur_detection/blur_detection.dart';
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: ImagePickerScreen(),
);
}
}
class ImagePickerScreen extends StatefulWidget {
@override
_ImagePickerScreenState createState() => _ImagePickerScreenState();
}
class _ImagePickerScreenState extends State<ImagePickerScreen> {
final ImagePicker _picker = ImagePicker();
bool? _isBlurred;
Future<void> _pickImage() async {
final XFile? image = await _picker.pickImage(source: ImageSource.gallery);
if (image != null) {
File selectedFile = File(image.path);
bool isBlurred = await BlurDetectionService.isImageBlurred(selectedFile);
setState(() {
_isBlurred = isBlurred;
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Blur Detection Example'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: _pickImage,
child: const Text('Pick an Image'),
),
if (_isBlurred != null)
Text(_isBlurred! ? 'Image is Blurred' : 'Image is Clear'),
],
),
),
);
}
}