import 'package:flutter/material.dart'; import 'package:smtias_capture/models/display_orientation.dart'; /// [child](向き調整前のコンテンツ)に表示向き変換を適用するウィジェット. /// /// 「生フレーム座標」のコンテンツを,撮影者が見る「表示後座標」へ変換する. /// 変換内容は [orientation](既定: [DisplayOrientation.attachmentDownward])に /// 従う.向きの定義は `DisplayOrientation` に一元化されており,変更時はそちらを /// 編集する(座標系・確認手順は SPEC_04 参照). /// /// この変換結果に対して [RegionCrop] が表示後座標 0.0–1.0 でクロップする. /// ライブプレビュー([child] = `CameraPreview`)とテスト([child] = 任意の画像)で /// 共通利用できるよう,向き変換のみを担い [child] を差し替え可能にしている. class OrientedPreview extends StatelessWidget { const OrientedPreview({ super.key, required this.child, this.orientation = DisplayOrientation.attachmentDownward, }); /// 向き調整前のコンテンツ(生フレーム座標). final Widget child; /// 適用する向き設定(単一の真実). final DisplayOrientation orientation; @override Widget build(BuildContext context) { return Transform( alignment: Alignment.center, transform: orientation.previewMatrix, child: child, ); } }