device_screenshot 0.0.8 copy "device_screenshot: ^0.0.8" to clipboard
device_screenshot: ^0.0.8 copied to clipboard

PlatformAndroid

A Flutter plugin that can helps you to take screenshot your overall device.

Device Screenshot Banner

Device Screenshot

💡 Overview #

A Flutter plugin that can helps you to take screenshot your overall device using media projection and foreground service.

The plugin currently supports Android only and doesn't support IOS because the feature of media projection is not available there

💻 Usage #

First, add device_screenshot as a dependency in your pubspec.yaml file.

dependencies:
  flutter:
    sdk: flutter

  device_screenshot: ^update_version
copied to clipboard

Don't forget to flutter pub get.

🔧 Setup #

Set the minimum SDK version to 21 or higher in your android/app/build.gradle file:

android {
    defaultConfig {
        ...
        minSdkVersion 21 // Set this to 21 or higher
        ...
    }
}
copied to clipboard
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="...">
  ...

  <application
        ...
        ...>

        <activity
            ...
            ...>

        <!--Add this-->
        <service
            android:name="com.flutter.device_screenshot.src.MediaProjectionService"
            android:enabled="true"
            android:exported="false"
            android:foregroundServiceType="mediaProjection"
            android:permission="TODO"
            android:stopWithTask="false"
            />
        <!--end-->

        ...
  ...
  </application>
</manifest>
copied to clipboard

Import the package:

import 'package:device_screenshot/device_screenshot.dart';
copied to clipboard

Use the singleton instance of DeviceScreenshot to access all the available methods, for example:

DeviceScreenshot.instance.checkMediaProjectionService()
copied to clipboard

📱 To take screenshot #

At first you need to run foreground service and for this

DeviceScreenshot.instance.requestMediaProjection()
copied to clipboard

Now you are ready to take your Device Screenshot.

Uri? uri = await DeviceScreenshot.instance.takeScreenshot()
copied to clipboard
8
likes
140
points
31
downloads

Publisher

unverified uploader

Weekly Downloads

2024.10.03 - 2025.04.17

A Flutter plugin that can helps you to take screenshot your overall device.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on device_screenshot