截图出现在某些设备上(tecno be8)

问题描述 投票:0回答:0

issue

我正在使用flutter flutter捕获窗口小部件的屏幕截图。但是,在某些设备(例如

Tecnobe8
)上,捕获的图像出现(垂直翻转).

FlutterSDK版本:

    FlutterSDK
  • :3.29.0 thist backage尝试:
  • (但同样的问题)
  • 代码我正在使用
  • 我正在使用以下代码捕获和显示图像:

RenderRepaintBoundary

UI结构

screenshot: ^3.0.0

问题

屏幕截图出现a镜像
仅在某些设备上(例如tecno be8)
。 其他设备正确捕获图像。

镜像似乎是一个GPU渲染问题。

我尝试了什么
  • 改变import 'dart:typed_data'; import 'dart:ui' as ui; import 'package:flutter/material.dart'; final GlobalKey _globalKey = GlobalKey(); Future<Uint8List?> _captureWidget() async { try { // Find the RenderRepaintBoundary RenderRepaintBoundary boundary = _globalKey.currentContext!.findRenderObject() as RenderRepaintBoundary; // Convert the widget to an image ui.Image image = await boundary.toImage(pixelRatio: 3.0); // Adjust pixelRatio for quality // Convert the image to a byte array (Uint8List) ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); Uint8List uint8List = byteData!.buffer.asUint8List(); return uint8List; } catch (e) { print('Error capturing widget: $e'); return null; } } // Display the captured image void _showCapturedImage(BuildContext context, Uint8List image) { showDialog( context: context, builder: (context) { return AlertDialog( content: Image.memory(image), actions: [ TextButton( onPressed: () => Navigator.pop(context), child: Text('Close'), ), ], ); }, ); }
  • 使用
  • RepaintBoundary( key: _globalKey, child: Container( padding: EdgeInsets.all(20), color: Colors.blue, child: Text( 'Hello, World!', style: TextStyle(color: Colors.white, fontSize: 24), ), ), ),
  • 软件包而不是
  • pixelRatio
  • (同一问题)。
检查颤音版本,但问题仍然存在。

可能的解决方案?

  • 我怀疑图像需要在显示之前将图像翻转。如果有人遇到了这个问题,我该如何解决?
    问题是,捕获的图像在某些设备上垂直翻转。
    
    	
  • 您无法自行解决此问题,因为它源于扑动本身。此问题不仅在创建屏幕截图时,而且在应用着色器时也会发生。但是,我已经在Flutter
  • Herey中提交了一个错误报告。
    BTW仅用于您的信息,
    toImage()
    软件包还在引擎盖下使用
    screenshot
  • 。因此,即使您使用该软件包,结果也将保持不变。
flutter screenshot
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.