import 'package:flutter/services.dart'; /// Camera2 API を使用してフル解像度の YUV 画像をキャプチャするサービス. class RawCaptureService { static const _channel = MethodChannel('com.example.mini_tias/raw_capture'); /// フロントカメラからフル解像度の YUV データをキャプチャする. /// /// 返り値は YUV データを含む Map: /// - width, height: 画像サイズ /// - yPlane, uPlane, vPlane: YUV プレーンのバイトデータ /// - yRowStride, uvRowStride, uvPixelStride: ストライド情報 Future> captureFullResolutionYuv() async { final result = await _channel .invokeMethod('captureFullResolutionYuv') .timeout( const Duration(seconds: 30), onTimeout: () => throw Exception('カメラキャプチャがタイムアウトしました'), ); return Map.from(result as Map); } /// MediaStore にファイルを登録し,PC から MTP で見えるようにする. Future scanFile(String path) async { await _channel.invokeMethod('scanFile', {'path': path}); } }