cameraService static method

String cameraService(
  1. String projectName
)

Implementation

static String cameraService(String projectName) {
  return '''
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:$projectName/core/services/feature_service.dart';

/// Simple camera/gallery helper.
///
/// Usage:
/// final file = await CameraService.pickImageFromCamera();
/// final file = await CameraService.pickImageFromGallery();
class CameraService {
static final ImagePicker _picker = ImagePicker();

/// Pick an image using the device camera.
static Future<File?> pickImageFromCamera() async {
  if (!FeatureService.isCameraEnabled) {
    throw Exception('Camera feature is disabled. Enable it in settings.');
  }

  final XFile? picked = await _picker.pickImage(
    source: ImageSource.camera,
    imageQuality: 80,
  );
  if (picked == null) return null;
  return File(picked.path);
}

/// Pick an image from the gallery.
static Future<File?> pickImageFromGallery() async {
  if (!FeatureService.isImagePickerEnabled) {
    throw Exception('Image picker feature is disabled. Enable it in settings.');
  }

  final XFile? picked = await _picker.pickImage(
    source: ImageSource.gallery,
    imageQuality: 80,
  );
  if (picked == null) return null;
  return File(picked.path);
}
}
''';
}