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( Positioned.fill(
child: VideoPlayer(videoController!), child: Center(
), child: AspectRatio(
Screenshot( aspectRatio: videoController!.value.aspectRatio,
controller: screenshotController, child: Stack(
child: LayersViewer( children: [
layers: layers.where((x) => !x.isDeleted).toList(), Positioned.fill(
onUpdate: () { child: VideoPlayer(videoController!),
for (final layer in layers) { ),
layer.isEditing = false; Positioned.fill(
if (layer.isDeleted) { child: _buildScreenshotViewer(),
removedLayers.add(layer); ),
} ],
} ),
layers = layers.where((x) => !x.isDeleted).toList(); ),
setState(() {}); ),
}, )
), else
), _buildScreenshotViewer(),
], ],
), ),
), ),

View file

@ -21,16 +21,14 @@ 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( child: VideoPlayer(
color: Colors.transparent, videoController!,
), ),
child: VideoPlayer(
videoController!,
), ),
), ),
) )