mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Preserve tablet camera aspect ratio
Signed-off-by: kenny lopez <klopez4212@gmail.com>
This commit is contained in:
@@ -177,6 +177,21 @@ class _CameraFeed extends StatelessWidget {
|
||||
final previewSize = controller.value.previewSize;
|
||||
if (previewSize == null) return const ColoredBox(color: Colors.black);
|
||||
|
||||
final isTablet = MediaQuery.sizeOf(context).shortestSide >= 600;
|
||||
|
||||
// The tablet workspace gives the composer a tall, bounded panel instead
|
||||
// of the phone's wide attachment surface. Let CameraPreview retain the
|
||||
// camera's reported ratio in that panel; forcing its rotated preview size
|
||||
// through FittedBox here makes Android stretch the feed in a narrow pane.
|
||||
if (isTablet) {
|
||||
return Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: controller.value.aspectRatio,
|
||||
child: camera.CameraPreview(controller),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ClipRect(
|
||||
child: FittedBox(
|
||||
fit: BoxFit.cover,
|
||||
|
||||
Reference in New Issue
Block a user