Open xlyashuk opened 2 years ago
Hi @xlyashuk, Thanks for filing the issue. I am able to reproduce the issue on stable and the master channel. On Taking the screenshot error is thrown and a blank image is displayed. The Screenshot can be taken without the CameraPreview (Platformview).
A reproducible code sample can be found in the original post.
Duplicate of https://github.com/flutter/flutter/issues/83856 (closed)
cc: @blasten
I also have the same problem. But in my case, I must take a screenshot of the PlatformView
widget.
So, is there a solution for this yet?
Have the same problem.
I don't think Flutter can take a screenshot of platform provided textures today. Especially if those textures are from protected sources. I believe the linked issue was for tests. cc @blasten to confirm.
This is the same issue as https://github.com/flutter/flutter/issues/25306, but it's not solved. Instead, https://github.com/flutter/flutter/issues/83856 turn this into a test issue, then https://github.com/flutter/flutter/issues/97853 turn this into a test coverage issue. I think @blasten has already done some good work but the scope is not correct at present. We should definitely support this in the runtime, not only for tests.
Steps to Reproduce
- Execute
flutter run
on the code sample- Press icon button to take screenshot from camera preview.
Expected results: Screenshot should contain camera preview picture.
Actual results: Screenshot doesn't include camera view.
I tested it on Samsung S9, Samsung S20 using Flutter 2.10.5 and 2.13.0-0.2.pre. Same issue happen on iOS, tested on iPhone 12 Pro Max, iOS 15.2.1, Flutter 2.10.5.
I'm aware of existing issues like #25306 which all point to resolved #83856 (comment). However I can't confirm that this feature works.
Code sample pubspec.yaml flutter doctor -v Screenshots Camera surface view:
Screenshot result:
try https://pub.dev/packages/ff_native_screenshot to get screenshot by native
I have same problem when taking screenshot from Qr Code Scanner
Still having the same issue
Do we have solution to this issue?
Is there even any beta/master channel work on this? It seems a rudimentary feature. Please convert the test functionality into runtime.
Hey Flutter-Team,
is there any update on this issue?
It still hasn't been fixed yet after 2 years.
Does anyone have solution?
Steps to Reproduce
flutter run
on the code sampleExpected results: Screenshot should contain camera preview picture.
Actual results: Screenshot doesn't include camera view.
I tested it on Samsung S9, Samsung S20 using Flutter 2.10.5 and 2.13.0-0.2.pre. Same issue happen on iOS, tested on iPhone 12 Pro Max, iOS 15.2.1, Flutter 2.10.5.
I'm aware of existing issues like https://github.com/flutter/flutter/issues/25306 which all point to resolved https://github.com/flutter/flutter/issues/83856#issuecomment-1072896951. However I can't confirm that this feature works.
Code sample
```import 'dart:async'; import 'dart:typed_data'; import 'dart:ui'; import 'package:camera/camera.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; Futurepubspec.yaml
``` name: screenshot_test description: A new Flutter project. publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 1.0.0+1 environment: sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter cupertino_icons: ^1.0.2 camera: ^0.9.4+21 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 flutter: uses-material-design: true ```flutter doctor -v
``` [√] Flutter (Channel beta, 2.13.0-0.2.pre, on Microsoft Windows [Version 10.0.19042.1288], locale ru-RU) • Flutter version 2.13.0-0.2.pre at e:\Programs\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 8662e22bac (10 days ago), 2022-04-20 08:21:52 -0700 • Engine revision 24a02fa5ee • Dart version 2.17.0 (build 2.17.0-266.5.beta) • DevTools version 2.12.2 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Alexey\AppData\Local\Android\sdk • Platform android-31, build-tools 30.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.5.5) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools • Visual Studio Build Tools 2019 version 16.5.30104.148 • Windows 10 SDK version 10.0.18362.0 [√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) [√] VS Code (version 1.64.2) • VS Code at C:\Users\Alexey\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19042.1288] • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.127 • Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.66 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! D:\Work\Cars\Tests\Flutter\screenshot_test>flutter doctor -v [√] Flutter (Channel beta, 2.13.0-0.2.pre, on Microsoft Windows [Version 10.0.19042.1288], locale ru-RU) • Flutter version 2.13.0-0.2.pre at e:\Programs\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 8662e22bac (10 days ago), 2022-04-20 08:21:52 -0700 • Engine revision 24a02fa5ee • Dart version 2.17.0 (build 2.17.0-266.5.beta) • DevTools version 2.12.2 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Alexey\AppData\Local\Android\sdk • Platform android-31, build-tools 30.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.5.5) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools • Visual Studio Build Tools 2019 version 16.5.30104.148 • Windows 10 SDK version 10.0.18362.0 [√] Android Studio (version 2021.1) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.11+9-b60-7590822) [√] VS Code (version 1.64.2) • VS Code at C:\Users\Alexey\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19042.1288] • Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.127 • Edge (web) • edge • web-javascript • Microsoft Edge 87.0.664.66 [√] HTTP Host Availability • All required HTTP hosts are available • No issues found! ```Screenshots Camera surface view:
Screenshot result: