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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
pixelRatio = MediaQuery.of(context).devicePixelRatio; pixelRatio = MediaQuery.of(context).devicePixelRatio;
@ -784,26 +803,27 @@ class _ShareImageEditorView extends State<ShareImageEditorView> {
width: currentImage.width / pixelRatio, width: currentImage.width / pixelRatio,
child: Stack( child: Stack(
children: [ children: [
if (videoController != null) if (videoController != null &&
videoController!.value.isInitialized)
Positioned.fill(
child: Center(
child: AspectRatio(
aspectRatio: videoController!.value.aspectRatio,
child: Stack(
children: [
Positioned.fill( Positioned.fill(
child: VideoPlayer(videoController!), child: VideoPlayer(videoController!),
), ),
Screenshot( Positioned.fill(
controller: screenshotController, child: _buildScreenshotViewer(),
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(() {});
},
), ),
), ),
),
)
else
_buildScreenshotViewer(),
], ],
), ),
), ),

View file

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