https://github.com/alienkevin/capture_screenshot
https://github.com/alienkevin/capture_screenshot
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alienkevin/capture_screenshot
- Owner: AlienKevin
- License: mit
- Created: 2023-12-19T21:18:40.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-19T22:10:43.000Z (about 2 years ago)
- Last Synced: 2025-01-23T21:25:10.610Z (about 1 year ago)
- Language: Kotlin
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# capture_screenshot
A Flutter plugin for capturing full screenshots on Android.
iOS is not supported because it is not possible to capture full screenshots on iOS.
# Usage
See the example app under `example/` for a complete demo.
```dart
try {
// Adjust the delayInMilliseconds to suit your needs
final imageBytes = await _captureScreenshotPlugin.captureScreenshot(
delayInMilliseconds: 200);
// imageBytes will be null if fails to take a screenshot
// On success, imageBytes will contain the bytes of the screenshot image in PNG format
if (imageBytes != null) {
screenshot = Image.memory(imageBytes);
print("Successfully taken a screenshot!");
} else {
print("Failed to take a screenshot!");
}
} on PlatformException catch (e) {
print("Failed to take a screenshot!");
print(e);
screenshot = null;
}
```
# Caveats
On Android 14 (API level 34), the user will be prompted to give consent before each taking screenshot.
See the following links for more information:
* https://developer.android.com/about/versions/14/behavior-changes-14#media-projection-consent
* https://stackoverflow.com/questions/76804553/reusing-media-projection-intent-on-android-14
# Inspiration
* media_projection_screenshot plugin by liasica: https://pub.dev/packages/media_projection_screenshot
# License
MIT License