fix aspect ratio
Some checks are pending
Flutter analyze & test / flutter_analyze_and_test (push) Waiting to run

This commit is contained in:
otsmr 2026-07-07 22:06:51 +02:00
parent 1126d4172b
commit 3cdbd69d88
2 changed files with 46 additions and 28 deletions

View file

@ -667,6 +667,25 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
}
}
Widget _buildScreenshotViewer() {
return Screenshot(
controller: screenshotController,
child: LayersViewer(
layers: layers.where((x) => !x.isDeleted).toList(),
onUpdate: () {
for (final layer in layers) {
layer.isEditing = false;
if (layer.isDeleted) {
removedLayers.add(layer);
}
}
layers = layers.where((x) => !x.isDeleted).toList();
setState(() {});
},
),
);
}
@override
Widget build(BuildContext context) {
pixelRatio = MediaQuery.of(context).devicePixelRatio;
@ -784,26 +803,27 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
width: currentImage.width / pixelRatio,
child: Stack(
children: [
if (videoController != null)
if (videoController != null &&
videoController!.value.isInitialized)
Positioned.fill(
child: VideoPlayer(videoController!),
),
Screenshot(
controller: screenshotController,
child: LayersViewer(
layers: layers.where((x) => !x.isDeleted).toList(),
onUpdate: () {
for (final layer in layers) {
layer.isEditing = false;
if (layer.isDeleted) {
removedLayers.add(layer);
}
}
layers = layers.where((x) => !x.isDeleted).toList();
setState(() {});
},
),
),
child: Center(
child: AspectRatio(
aspectRatio: videoController!.value.aspectRatio,
child: Stack(
children: [
Positioned.fill(
child: VideoPlayer(videoController!),
),
Positioned.fill(
child: _buildScreenshotViewer(),
),
],
),
),
),
)
else
_buildScreenshotViewer(),
],
),
),

View file

@ -21,16 +21,14 @@ class MediaContentRenderer extends StatelessWidget {
Widget build(BuildContext context) {
return Stack(
children: [
if (videoController != null)
if (videoController != null && videoController!.value.isInitialized)
Positioned.fill(
child: PhotoView.customChild(
initialScale: PhotoViewComputedScale.contained,
minScale: PhotoViewComputedScale.contained,
backgroundDecoration: const BoxDecoration(
color: Colors.transparent,
),
child: VideoPlayer(
videoController!,
child: Center(
child: AspectRatio(
aspectRatio: videoController!.value.aspectRatio,
child: VideoPlayer(
videoController!,
),
),
),
)