flutter_screenshot 0.1.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 73

flutter_screenshot #

Flutter screenshot originally from screenshot package by extend more methods.

Getting Started #

    //single screenshot
    void _testScreenshot() {
    
    screenshotController.captureAsFile().then((File file){
      print(file);
    });

    screenshotController.captureAsByteData().then((ByteData byteData){
      print(byteData);
    });

    screenshotController.captureAsUint8List().then((Uint8List uint8List){
      print(Uint8List);
    });

    screenshotController.captureAsUiImage().then((res) {
      ui.Image image = res;
      print(image);
    });
  }

    body: Container(
          alignment: Alignment.center,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ScreenshotContainer(
                controller: screenshotController,
                child: Text("Sreenshot me now"),
              ),
              
              
              RaisedButton(
                onPressed: () {
                  _testScreenshot();
                },
                child: Text("Pressed me"),
              ),
            ],
          ),
        )
  bool _isGenrated = false;
  List<ScreenshotController> screenshotControllers =
      List<ScreenshotController>.generate(5, (i) => ScreenshotController());
  List<Uint8List> _datas = [];

  //multi screenshot
  void _testMultiScreenshot() async {
    List<Uint8List> datas = await Future.wait(screenshotControllers
        .map((ScreenshotController screenshotController) async =>
            await screenshotController.captureAsUint8List(pixelRatio: 10))
        .toList());
    print(datas);
    setState(() {
      _datas = datas;
      _isGenrated = true;
    });
  }
  body: Container(
          alignment: Alignment.center,
          child: _isGenrated && _datas.length > 0
              ? ListView.builder(
              itemCount: _datas.length,
              itemBuilder: (_, index) {
                  return Image.memory(_datas[index]);
                })
              : ListView.builder(
                  itemCount: screenshotControllers.length,
                  itemBuilder: (_, index) {
                    return ScreenshotContainer(
                      controller: screenshotControllers[index],
                      child: Text("Sreenshot me now", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.blue),),
                    );
                  }),
    floatingActionButton: RaisedButton(
          onPressed: () {
            _testMultiScreenshot();
          },
          child: Text("Pressed me"),
        ),              

0.1.0+1 #

  • TODO: detail read me

0.1.0 #

  • TODO: examle of multi snapshot and license

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_screenshot/flutter_screenshot.dart';
import 'dart:ui' as ui;

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isGenrated = false;
  List<ScreenshotController> screenshotControllers =
      List<ScreenshotController>.generate(5, (i) => ScreenshotController());
  List<Uint8List> _datas = [];


  ScreenshotController screenshotController = ScreenshotController();


  @override
  void initState() {
    super.initState();
  }

  //multi screenshot
  void _testMultiScreenshot() async {
    List<Uint8List> datas = await Future.wait(screenshotControllers
        .map((ScreenshotController screenshotController) async =>
            await screenshotController.captureAsUint8List(pixelRatio: 10))
        .toList());
    print(datas);
    setState(() {
      _datas = datas;
      _isGenrated = true;
    });
  }

  //single screenshot
  void _testScreenshot() {

    screenshotController.captureAsFile().then((File file){
      print(file);
    });

    screenshotController.captureAsByteData().then((ByteData byteData){
      print(byteData);
    });

    screenshotController.captureAsUint8List().then((Uint8List uint8List){
      print(Uint8List);
    });

    screenshotController.captureAsUiImage().then((res) {
      ui.Image image = res;
      print(image);
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        //multi-screenshot
        body: Container(
          alignment: Alignment.center,
          child: _isGenrated && _datas.length > 0
              ? ListView.builder(
              itemCount: _datas.length,
              itemBuilder: (_, index) {
                  return Image.memory(_datas[index]);
                })
              : ListView.builder(
                  itemCount: screenshotControllers.length,
                  itemBuilder: (_, index) {
                    return ScreenshotContainer(
                      controller: screenshotControllers[index],
                      child: Text("Sreenshot me now", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold, color: Colors.blue),),
                    );
                  }),
         //single-screenshot
//          body: Container(
//            alignment: Alignment.center,
//            child: Column(
//              mainAxisAlignment: MainAxisAlignment.center,
//              children: <Widget>[
//                ScreenshotContainer(
//                  controller: screenshotController,
//                  child: Text("Sreenshot me now"),
//                ),
//
//
//                RaisedButton(
//                  onPressed: () {
//                    _testScreenshot();
//                  },
//                  child: Text("Pressed me"),
//                ),
//              ],
//            ),
//          ),

        ),
        floatingActionButton: RaisedButton(
          onPressed: () {
            _testMultiScreenshot();
          },
          child: Text("Pressed me"),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  flutter_screenshot: ^0.1.0+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:flutter_screenshot/flutter_screenshot.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform android

Because:

  • package:flutter_screenshot/flutter_screenshot.dart that imports:
  • package:flutter_screenshot/src/ScreenshotContainer.dart that imports:
  • package:flutter_screenshot/src/ScreenshotController.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform ios

Because:

  • package:flutter_screenshot/flutter_screenshot.dart that imports:
  • package:flutter_screenshot/src/ScreenshotContainer.dart that imports:
  • package:flutter_screenshot/src/ScreenshotController.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform macos

Because:

  • package:flutter_screenshot/flutter_screenshot.dart that imports:
  • package:flutter_screenshot/src/ScreenshotContainer.dart that imports:
  • package:flutter_screenshot/src/ScreenshotController.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: linux

Package does not support Flutter platform web

Because:

  • package:flutter_screenshot/flutter_screenshot.dart that imports:
  • package:flutter_screenshot/src/ScreenshotContainer.dart that imports:
  • package:flutter_screenshot/src/ScreenshotController.dart that imports:
  • package:path_provider/path_provider.dart that declares support for platforms: android, ios, linux, macos

Package does not support Flutter platform windows

Because:

  • package:flutter_screenshot/flutter_screenshot.dart that imports:
  • package:flutter_screenshot/src/ScreenshotContainer.dart that imports:
  • package:flutter_screenshot/src/ScreenshotController.dart that imports:
  • package:path_provider/path_provider.dart that declares support for platforms: android, ios, linux, macos

Package not compatible with SDK dart

Because:

  • flutter_screenshot that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
path_provider ^1.6.5 1.6.11
Transitive dependencies
collection 1.14.12 1.14.13
file 5.2.1
intl 0.16.1
meta 1.1.8 1.2.1
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test