import 'package:flutter/services.dart'; /// Camera2 API を使用してフル解像度の YUV 画像をキャプチャするサービス. class RawCaptureService { static const _channel = MethodChannel('com.example.mini_tias/raw_capture'); /// フロントカメラからフル解像度の YUV データをキャプチャする. Future> captureFullResolutionYuv() async { final result = await _channel .invokeMethod('captureFullResolutionYuv') .timeout( const Duration(seconds: 30), onTimeout: () => throw Exception('カメラキャプチャがタイムアウトしました'), ); return Map.from(result as Map); } /// PixelCopy でカメラプレビュー領域のスナップショットを JPEG として取得する. Future capturePreviewFrame({ required int x, required int y, required int width, required int height, }) async { final result = await _channel.invokeMethod( 'capturePreviewFrame', {'x': x, 'y': y, 'width': width, 'height': height}, ); if (result == null) { throw Exception('プレビューフレームの取得に失敗しました'); } return result; } /// MediaStore にファイルを登録し,PC から MTP で見えるようにする. Future scanFile(String path) async { await _channel.invokeMethod('scanFile', {'path': path}); } }