This pub lets you share any kind of files (csv, mp4, png etc), take screenshot of the widgets you want and return as Image and share them directly as well in the form of an image.

Overview

share_files_and_screenshot_widgets

This pub lets you share any kind of files (csv, mp4, png etc), take screenshot of the widgets you want and return as Image and share them directly as well in the form of an image.

Usage

Example

To use this package :

  • add the dependency to your [pubspec.yaml] file.
  dependencies:
    flutter:
      sdk: flutter
    share_files_and_screenshot_widgets:

How to use

Take ScreenShot of Widgets

//define
GlobalKey previewContainer = new GlobalKey();

//wrap your widget with
RepaintBoundary(
  key: previewContainer,
  child: YourWidget()
),

//call this function for taking screenshot
ShareFilesAndScreenshotWidgets()
    .takeScreenshot(previewContainer, originalSize)
    .then((Image value) {
  setState(() {
    _image = value;
  });
});

Directly Share ScreenShot of Widgets

//define
GlobalKey previewContainer = new GlobalKey();

//wrap your widget with
RepaintBoundary(
  key: previewContainer,
  child: YourWidget()
),

//call this function for sharing screenshot
ShareFilesAndScreenshotWidgets().shareScreenshot(
  previewContainer,
  originalSize,
  "Title",
  "Name.png",
  "image/png",
  text: "This is the caption!");

Share Any Type of File

ByteData bytes =
    await rootBundle.load('assets/example.jpg');
Uint8List list = bytes.buffer.asUint8List();
ShareFilesAndScreenshotWidgets().shareFile(
    "Title", "Name.jpg", list, "image/jpg",
    text: "This is the caption!");
ByteData bytes =
    await rootBundle.load('assets/example.mp4');
Uint8List list = bytes.buffer.asUint8List();
ShareFilesAndScreenshotWidgets().shareFile(
    "Title", "Name.mp4", list, "video/mp4",
    text: "This is the caption!");
ByteData bytes =
    await rootBundle.load('assets/example.mp3');
Uint8List list = bytes.buffer.asUint8List();
ShareFilesAndScreenshotWidgets().shareFile(
    "Title", "Name.mp3", list, "audio/mp3",
    text: "This is the caption!");

License

Copyright 2020 Jay Mehta

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Example

As time based...

import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'dart:ui';
import 'package:share_files_and_screenshot_widgets/share_files_and_screenshot_widgets.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter ScreenShot Demo',
      theme: ThemeData(
        primarySwatch: Colors.deepOrange,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo ScreenShot Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Image _image;

  GlobalKey previewContainer = new GlobalKey();
  int originalSize = 800;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        body: SingleChildScrollView(
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: [
                RepaintBoundary(
                  key: previewContainer,
                  child: Container(
                    decoration: BoxDecoration(
                        border: Border.all(width: 1.5),
                        borderRadius: BorderRadius.circular(20),
                        color: Colors.deepPurple),
                    padding: EdgeInsets.all(15),
                    margin: EdgeInsets.all(20),
                    width: MediaQuery.of(context).size.width - 40,
                    height: MediaQuery.of(context).size.height,
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Text(
                          "This is a picture.",
                          style: TextStyle(
                              fontSize: 20,
                              fontWeight: FontWeight.bold,
                              color: Colors.white),
                        ),
                        Image.asset("assets/example.jpg"),
                        Text(
                          "There’s something so whimsical about these beautiful images that incorporate bokeh. It’s almost as if they could be from a different, magical world. We’ve loved watching the submissions fly in for our bokeh-themed Photo Quest by Meyer-Optik-Görlitz and selected 30+ of our favourites beautiful images to ignite your creative spark! The three lucky winners of this Quest are going to receive an incredible prize courtesy of master lens-crafters Meyer-Optik.",
                          style: TextStyle(color: Colors.white),
                        ),
                      ],
                    ),
                  ),
                ),
                Column(
                  mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                  children: [
                    Container(
                      child: RaisedButton(
                          child: Text("Take Screenshot!"),
                          onPressed: () {
                            ShareFilesAndScreenshotWidgets()
                                .takeScreenshot(previewContainer, originalSize)
                                .then((Image value) {
                              setState(() {
                                _image = value;
                              });
                            });
                          }),
                    ),
                    Container(
                        child: RaisedButton(
                            child: Text("Share Screenshot!"),
                            onPressed: () {
                              ShareFilesAndScreenshotWidgets().shareScreenshot(
                                  previewContainer,
                                  originalSize,
                                  "Title",
                                  "Name.png",
                                  "image/png",
                                  text: "This is the caption!");
                            })),
                    Container(
                        child: RaisedButton(
                            child: Text("Share Image!"),
                            onPressed: () async {
                              ByteData bytes =
                                  await rootBundle.load('assets/example.jpg');
                              Uint8List list = bytes.buffer.asUint8List();
                              ShareFilesAndScreenshotWidgets().shareFile(
                                  "Title", "Name.jpg", list, "image/jpg",
                                  text: "This is the caption!");
                            })),
                    Container(
                        child: RaisedButton(
                            child: Text("Share Video!"),
                            onPressed: () async {
                              ByteData bytes =
                                  await rootBundle.load('assets/example.mp4');
                              Uint8List list = bytes.buffer.asUint8List();
                              ShareFilesAndScreenshotWidgets().shareFile(
                                  "Title", "Name.mp4", list, "video/mp4",
                                  text: "This is the caption!");
                            })),
                    Container(
                        child: RaisedButton(
                            child: Text("Share Audio!"),
                            onPressed: () async {
                              ByteData bytes =
                                  await rootBundle.load('assets/example.mp3');
                              Uint8List list = bytes.buffer.asUint8List();
                              ShareFilesAndScreenshotWidgets().shareFile(
                                  "Title", "Name.mp3", list, "audio/mp3",
                                  text: "This is the caption!");
                            })),
                  ],
                ),
                _image != null ? _image : Center()
              ],
            ),
          ),
        ));
  }
}
Comments
  • Whatsapp share doesnt share the image

    Whatsapp share doesnt share the image

    Hi,

    When choosing the option to share to a whatsapp contact the screenshot is not shared, only the caption. Any other option (like facebook or email) do share the screenshot. What can be the issue here?

    Marco

    opened by mstolk 10
  • offset on iOS

    offset on iOS

    Hello, I have same trouble with other "screenshot and share" package. If I open share pop up, next I choose facebook, next I make fall the keyboard and after publish or cancel and close pop up, I have 1/4 of my screen with offset and impossible to remove without close app RPReplay_Final1598707827

    opened by nitneuq33000 7
  • Security IOS 'Save Image'

    Security IOS 'Save Image'

    Hi,

    I'm getting a 'CRASHING_DUE_TO_PRIVACY_VIOLATION' error while choosing 'Save Image' in the share popup on iOS. What kind of security settings do i need for this option? I added some to the plist but i think i'm missing some.

    Marco

    opened by mstolk 4
  • Hide certain elements within the widget from appearing the screenshot

    Hide certain elements within the widget from appearing the screenshot

    Thanks, for the code, it works fine. Questions, if I use a card instead of container and put an icon in the card to be pressed to screenshot and share the card. Is there a way to hide this icon from appearing in the card screenshot?

    Originally posted by @moosalim in https://github.com/JayTWWM/Share-Files-And-Screenshot-Widgets-Flutter/issues/1#issuecomment-674434890

    opened by moosalim 4
  • Not working in to capture and share cards generated by Listview Builder

    Not working in to capture and share cards generated by Listview Builder

    Not working when we want to capture and share cards generated by Listview Builder due to the requirement for unique key. if you can please fix this and provide example of implementation.

    opened by moosalim 4
  • Introduce null safety

    Introduce null safety

    Right now the package doesn't support null safety and that poses a problem with sound null safe projects.

    The library 'package:share_files_and_screenshot_widgets/share_files_and_screenshot_widgets.dart' is legacy, and should not be imported into a null safe library.

    opened by MrCsabaToth 3
  • added using title parameter as email subject

    added using title parameter as email subject

    As mentioned in https://github.com/JayTWWM/Share-Files-And-Screenshot-Widgets-Flutter/issues/21, sharing emails do not have a subject attached, even though the title parameter from .shareFile() can be used for that purpose.

    this commit adds using the title parameter passed to .shareFile() as the email's subject, as an INTENT_EXTRA_SUBJECT.

    opened by evanholt1 1
  • Upgrade to Android V2 embedding to not rely on deprecated API

    Upgrade to Android V2 embedding to not rely on deprecated API

    V2 is out there for a good while now and the time is ticking: Android Studio presents a warning

    The plugins bluetooth_enable, share_files_and_screenshot_widgets use a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if these plugins support the Android V2 embedding. Otherwise, consider removing them since a future release of Flutter will remove these deprecated APIs. If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

    opened by MrCsabaToth 1
  • iOS not able to share local Video File with Text in Whats App

    iOS not able to share local Video File with Text in Whats App

    ByteData bytes = await rootBundle.load(playListLocalPath); Uint8List list = bytes.buffer.asUint8List(); ShareFilesAndScreenshotWidgets().shareFile( "Title", "Name.mp4", list, "video/mp4", text: "This is the caption!" );

    opened by DeepashreeBallodi 1
  • Update dependencies & code for Flutter 2.0

    Update dependencies & code for Flutter 2.0

    The purpose of this PR is to be compatible with Flutter 2.0 and other packages targeting 2.0+. Basically there're 2 updates:

    • RaisedButton (deprecated in Flutter 2.0.1) replcement with ElevatedButton (new API)
    • Update path_provider: ^1.6.11 to path_provider: ^2.0.1
    opened by rootasjey 1
  • Error permission

    Error permission

    This my problem....

    E/DatabaseUtils(21057): java.lang.SecurityException: Permission Denial: reading com.twwm.share_files_and_screenshot_widgets.ShareFilesAndScreenshotWidgetsFileProvider uri content://coesma.nit.eletronica.fileprovider.share_files_and_screenshot_widgets/cache/segundaviaAitNIT.png from pid=21789, uid=1000 requires the provider be exported, or grantUriPermission()

    opened by VictorPadovan1997 1
  • csv... how?

    csv... how?

    I was happy to see the csv share option, but there is no example for it in the docs. What is the file type? How to export it? ShareFilesAndScreenshotWidgets().shareFile( "Title", "Name.csv", list, "text/csv", text: "This is the caption!");

    Thanks!

    This is the code i'm trying to get to work:

          final directory = await getApplicationDocumentsDirectory();
    
          File f = File('${directory.path}/mycsv.csv');
    
          String csv = const ListToCsvConverter().convert(data);
    
          await f.writeAsString(csv);
    
          var file_as_bytes = await f.readAsBytes();
    
          Uint8List list = file_as_bytes.buffer.asUint8List();
    
          ShareFilesAndScreenshotWidgets().shareFile(
              "Title", "Name.csv", list, "text/csv",
              text: "This is the caption!");
    
    opened by Lenzeg 0
  • email subject

    email subject

    When sharing through email services (gmail/outlook),

    the email's subject is always empty regardless of what i pass to .shareFile() . the body of the email is filled successfully by the title in .shareFile() though.

    how can i fill the email's Subject from .shareFile() ?

    example:

    ShareFilesAndScreenshotWidgets().shareFile(
            'title',  -> not used in email services
            'image.jpg',
            imageData,
            'image/jpg',
            text: "text", -> filled in email body
          );
    

    edit: after further testing, sometimes in IOS devices the text parameter is the email subject AND email body. even more weird.

    opened by evanholt1 0
  • notShowing on iPad

    notShowing on iPad

    Hello, it works correctly on Android and iPhone, but it doesn't open the share on iPad. Maybe is related to this issue:

    https://github.com/flutter/flutter/issues/47220

    Thank you in advance

    opened by maddionatoplus 0
Owner
Jay Mehta
I am a crazy programmer and developer!
Jay Mehta
IIITB Hogwarts is a project which aims at increasing students' interest in creating projects and giving them a platform to share them with others.

IIITB-Hogwarts This is going to be fun project for our college students. Thinking of bringing Harry Potter style group division into college. This is

Kartik Pant 5 Nov 9, 2022
A discord bot, made with Dart, which lets you run your own pure Dart code snippets directly via a discord ping, and get the output in an instant.

A discord bot, made with Dart, which lets you run your own pure Dart code snippets directly via a discord ping, and get the output in an instant.

Anikate De 3 Oct 21, 2022
BankGit helps you manage your account and transactions more efficiently by breaking your account into branches for various purposes and then making transactions directly from them.

Bank Git Web Hosted Here : https://bank-management-45848.web.app/ Bank Git is an application built with Flutter and Firebase to help you manage your b

Yash Johri 27 Dec 26, 2022
Scaape, a first-of-its-kind social hangout app that makes organizing group hangouts with people who share similar interests as simple as shooting fish in a barrel.

Inspiration Humans are social beings, hence socializing and meeting new people is an impulsive part of our nature, but due to this recent pandemic whi

Scaape 12 Jan 10, 2022
An app which shows the total number of covid cases, recovered, etc. As well as of particular country too.

covid_app Images of Project A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get

Priyam Soni 0 Oct 18, 2021
Kind of app that generally used to maintain our day-to-day tasks or list everything that we have to do.We can add more tasks at any time and delete a task that is completed.

todo_application A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Khaled Elnkhla 0 Nov 6, 2021
Application that consumes the Movie Database (TMDB) api to show and search any kind of movie with its actors.

# cartelera A new Flutter project. ## Getting Started This project is a starting point for a Flutter application. A few resources to get you start

null 2 Jan 11, 2022
Android app that converts an URL to markdown, and lets you share it to your favorite notes app.

markdownr Android app that converts an URL to markdown, and lets you share it to your favorite notes app. I've written this app to save articles I fou

Andrea Ghensi 41 Dec 10, 2022
Flutter Screenshot Library

A simple package to capture widgets as Images. Now you can also capture the widgets that are not rendered on the screen! This package wraps your widge

Sachin 225 Dec 19, 2022
FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to feel like part of the Flutter framework.

File Manager FileManager is a wonderful widget that allows you to manage files and folders, pick files and folders, and do a lot more. Designed to fee

Devs On Flutter 52 Dec 30, 2022
App to seamlessly share files/images from your phone to your pc

Self-Share App to seamlessly share files/images from your phone to your pc Image

Wahbi 1 May 28, 2022
Foodies-discovery-ui - One kind of food viewing app with flutter

foodies app One kind of food viewing app Screenshot This project is a basic idea

Munem Sarker 1 Jan 25, 2022
This is a smart farming app which helps farmers to remotely monitor their crop and take necessary actions. It also has a feature called disease detection.

Smart-Farming-App This is a smart farming app which helps farmers to remotely monitor their crop and take necessary actions. It has features called di

Nihar Shah 2 Jul 9, 2022
A Flutter project to take surveys of talks using emoticons 😀

smilemeter A Flutter project to take surveys of talks using emoticons ?? . The idea is to put a person in the exit way and get feedbacks from the publ

Salvatore Giordano 6 Feb 15, 2021
Quiz App - A Flutter project to take exam from different subjects

A Flutter project to take exam from different subjects. You can assign date, time and duration of the exam.

Aryanka Pawar 1 Sep 23, 2022
Plaso Connect is an application which acts as a one-stop solution where the people requiring blood plasma/oxygen can directly find and contact the donors and healthcare units as per their requirements

PLASO CONNECT - The Lifeline A one-stop platform for COVID relief resources -- Connecting patients with Plasma donors and oxygen suppliers. Built for

Niloy Sikdar 11 Oct 28, 2022
Algorithm Toolbox is an Android app for C++, Python and DART algorithms. It shows the codes as well as its explanation with various examples.

AlgoKing Algorithm Toolbox is an Android app for C++, Python and DART algorithms. It shows the codes as well as its explanation with various examples.

Hash Studios 5 Sep 13, 2022
"A portable tool for displaying, searching, studying well known books from the google books api"

google_books_api A new Flutter application. Getting Started An Easy to use portable Google books reader, Allow authenication flow of users across the

Godslove lee 4 Jul 11, 2022