All Projects → SachinGanesh → Screenshot

SachinGanesh / Screenshot

Licence: mit
Flutter Screenshot Library

Programming Languages

dart
5743 projects
dartlang
94 projects

Projects that are alternatives of or similar to Screenshot

Flutter native ads
Show AdMob Native Ads use PlatformView
Stars: ✭ 63 (-37%)
Mutual labels:  flutter-plugin
Flutter web auth
Flutter plugin for authenticating a user with a web service
Stars: ✭ 81 (-19%)
Mutual labels:  flutter-plugin
Octo image
A multifunctional Flutter image widget
Stars: ✭ 97 (-3%)
Mutual labels:  flutter-plugin
Stereo
A Flutter plugin for playing music on iOS and Android.
Stars: ✭ 66 (-34%)
Mutual labels:  flutter-plugin
Intent
A simple Flutter plugin to deal with Android Intents, written with ❤️
Stars: ✭ 79 (-21%)
Mutual labels:  flutter-plugin
Json to form
A flutter plugin to use convert Json to Form
Stars: ✭ 82 (-18%)
Mutual labels:  flutter-plugin
Flutterradioplayer
Flutter Radio Player, A Plugin to handle streaming audio without a hassle
Stars: ✭ 59 (-41%)
Mutual labels:  flutter-plugin
Launch review
A Flutter plugin to assist in leaving user reviews/ratings in the Google Play Store. Supports both Android and iOS.
Stars: ✭ 98 (-2%)
Mutual labels:  flutter-plugin
Firebase dart sdk
Unofficial Firebase Flutter SDK. Maintainer: @long1eu
Stars: ✭ 80 (-20%)
Mutual labels:  flutter-plugin
Flutter weather bg
A rich and cool weather dynamic background plug-in
Stars: ✭ 89 (-11%)
Mutual labels:  flutter-plugin
Flutter Permission Handler
Permission plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.
Stars: ✭ 1,144 (+1044%)
Mutual labels:  flutter-plugin
Flutter Otp Authentication
A Flutter based OTP Authentication component, used to verify your mobile number with OTP (One Time Password) using Firebase Authentication.
Stars: ✭ 78 (-22%)
Mutual labels:  flutter-plugin
In app review
A Flutter plugin for showing the In-App Review/System Rating pop up on Android, IOS, and MacOS. It makes it easy for users to rate your app.
Stars: ✭ 85 (-15%)
Mutual labels:  flutter-plugin
Flutter appavailability
A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.
Stars: ✭ 63 (-37%)
Mutual labels:  flutter-plugin
Amap location fluttify
高德地图 定位组件 Flutter插件
Stars: ✭ 97 (-3%)
Mutual labels:  flutter-plugin
Flutter svg
SVG parsing, rendering, and widget library for Flutter
Stars: ✭ 1,113 (+1013%)
Mutual labels:  flutter-plugin
Flutter plugin pdf viewer
A flutter plugin for handling PDF files. Works on both Android & iOS
Stars: ✭ 81 (-19%)
Mutual labels:  flutter-plugin
Painter
A simple flutter widget to paint with your fingers
Stars: ✭ 99 (-1%)
Mutual labels:  flutter-plugin
Flutter Apps Collection
This is a repository of a collection of apps made in flutter
Stars: ✭ 98 (-2%)
Mutual labels:  flutter-plugin
Flutter inappwebview
A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
Stars: ✭ 1,259 (+1159%)
Mutual labels:  flutter-plugin

screenshot

A simple plugin to capture widgets as Images.

This plugin wraps your widgets inside RenderRepaintBoundary

Source

Getting Started

This handy plugin can be used to capture any Widget including full screen screenshots & individual widgets like Text().

  1. Create Instance of Screenshot Controller
class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;
  Uint8List _imageFile;

  //Create an instance of ScreenshotController
  ScreenshotController screenshotController = ScreenshotController(); 

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }
  ...
}
  1. Wrap the widget that you want to capture inside Screenshot Widget. Assign the controller to screenshotController that you have created earlier
Screenshot(
    controller: screenshotController,
    child: Text("This text will be captured as image"),
),
  1. Take the screenshot by calling capture method. This will return a Uint8List
screenshotController.capture().then((Uint8List image) {
    //Capture Done
    setState(() {
        _imageFile = image;
    });
}).catchError((onError) {
    print(onError);
});

Example:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Container(
        child: new Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Screenshot(
                controller: screenshotController,
                child: Column(
                  children: <Widget>[
                    Text(
                      'You have pushed the button this many times:' +
                          _counter.toString(),
                    ),
                    FlutterLogo(),
                  ],
                ),
              ),
              _imageFile != null ? Image.memory(_imageFile) : Container(),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          _incrementCounter();
          _imageFile = null;
          screenshotController
              .capture()
              .then((Uint8List image) async {
            //print("Capture Done");
            setState(() {
              _imageFile = image;
            });
            final result =
                await ImageGallerySaver.save(image); // Save image to gallery,  Needs plugin  https://pub.dev/packages/image_gallery_saver
            print("File Saved to Gallery");
          }).catchError((onError) {
            print(onError);
          });
        },
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
screenshot

Saving images to Specific Location

For this you can use captureAndSave method by passing directory location. By default, the captured image will be saved to Application Directory. Custom paths can be set using path parameter. Refer path_provider

Note

Method captureAndSave is not supported for web.

final directory = (await getApplicationDocumentsDirectory ()).path; //from path_provide package
String fileName = DateTime.now().microsecondsSinceEpoch;
path = '$directory';

screenshotController.captureAndSave(
    path //set path where screenshot will be saved
    fileName:fileName 
);

Saving images to Gallery

If you want to save captured image to Gallery, Please use https://github.com/hui-z/image_gallery_saver Example app uses the same to save screenshots to gallery.

Note:

Captured image may look pixelated. You can overcome this issue by setting value for pixelRatio

The pixelRatio describes the scale between the logical pixels and the size of the output image. It is independent of the window.devicePixelRatio for the device, so specifying 1.0 (the default) will give you a 1:1 mapping between logical pixels and the output pixels in the image.

screenshotController.capture(
    pixelRatio: 1.5
)

Sometimes rastergraphics like images may not be captured by the plugin with default configurations. The issue is discussed here.

...screenshot is taken before the GPU thread is done rasterizing the frame 
so the screenshot of the previous frame is taken, which is wrong.

The solution is to add a small delay before capturing.

screenshotController.capture(delay: Duration(milliseconds: 10))

Known Bugs

  • Image will not be updated if same filename is given multiple times
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].