Files
BadNote/lib/services/camera_service.dart
T

20 lines
710 B
Dart
Raw Normal View History

import 'package:image_picker/image_picker.dart';
/// Thin wrapper around image_picker for camera capture and gallery selection.
class CameraService {
final ImagePicker _picker = ImagePicker();
/// Capture a photo using the device camera.
/// Returns the file path, or null if the user cancelled.
Future<String?> capturePhoto() async {
final XFile? image = await _picker.pickImage(source: ImageSource.camera);
return image?.path;
}
/// Pick an image from the device gallery.
/// Returns the file path, or null if the user cancelled.
Future<String?> pickFromGallery() async {
final XFile? image = await _picker.pickImage(source: ImageSource.gallery);
return image?.path;
}
}