Search packages, repositories and app categories

GitHub repositoryHasanToufiqAhamed/device_screenshot

device_screenshot

HasanToufiqAhamed/device_screenshot open-source repository details.

device_screenshot project cover
Stars
4
Forks
2
Last push (UTC)
May 13, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

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

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
        ...
    }
}
<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>

Import the package:

import 'package:device_screenshot/device_screenshot.dart';

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

DeviceScreenshot.instance.checkMediaProjectionService()

📱 To take screenshot

At first you need to run foreground service and for this

DeviceScreenshot.instance.requestMediaProjection()

Now you are ready to take your Device Screenshot.

Uri? uri = await DeviceScreenshot.instance.takeScreenshot()
Hasan Toufiq Ahamed GitHub avatar
GitHub author

Hasan Toufiq Ahamed ↗

Mobile Application Developer | Flutter Developer

Apsis Solutions LimitedDhaka, Bangladehs
LanguagesKotlinDart

Packages published by this repository

Dependencies used

Dependency list 4 items

  • flutter{"sdk":"flutter"}
  • plugin_platform_interface^2.0.2
  • flutter_testDevelopment{"sdk":"flutter"}
  • flutter_lintsDevelopment^2.0.0

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗