Use EdgeDetection.detectEdge to start a live camera session that allows edge detection and an option to select from the gallery.
Note: You must first request camera permissions using permission_handler and generate a valid file path where the cropped image will be saved.
import 'package:edge_detection/edge_detection.dart';
// 1. Request permissions
bool isCameraGranted = await Permission.camera.request().isGranted;
if (!isCameraGranted) {
isCameraGranted = await Permission.camera.request() == PermissionStatus.granted;
}
if (!isCameraGranted) return;
// 2. Generate filepath
String imagePath = join((await getApplicationSupportDirectory()).path,
"${(DateTime.now().millisecondsSinceEpoch / 1000).round()}.jpeg");
// 3. Detect edges
try {
bool success = await EdgeDetection.detectEdge(imagePath,
canUseGallery: true,
androidScanTitle: 'Scanning',
androidCropTitle: 'Crop',
androidCropBlackWhiteTitle: 'Black White',
androidCropReset: 'Reset',
);
} catch (e) {
print(e);
}