Coder Social home page Coder Social logo

trojan9 / davinci Goto Github PK

View Code? Open in Web Editor NEW

This project forked from imgkl/davinci

0.0 0.0 0.0 340 KB

A flutter package to convert any widget to an Image.

Home Page: https://pub.dev/packages/davinci

License: MIT License

Ruby 4.12% C++ 34.78% C 2.19% Objective-C 0.06% Kotlin 0.19% Dart 25.16% Swift 1.96% HTML 2.82% CMake 28.73%

davinci's Introduction

Davinci Supported Platforms Pub version MIT Lisence linter Codacy Badge PR's welcome


A package to convert any widget to an image which can be saved locally or can be shared to other apps and chats.

📹 Preview

ℹī¸ Usage

⚠ī¸ From version 2.1.0, passing context in required now in the click and offStage methods, this is due to some deprecated methods in Flutter version 3.10

Prerequisites

on iOS

Add the following keys to your Info.plist file, located in <project root>/ios/Runner/Info.plist:

  • NSPhotoLibraryUsageDescription - describe why your app needs permission for the photo library. This is called Privacy - Photo Library Usage Description in the visual editor.

on Android

  • android.permission.WRITE_EXTERNAL_STORAGE - Permission for usage of external storage

Imports

import 'package:davinci/core/davinci_capture.dart';
import 'package:davinci/davinci.dart';

Pseudo code

If the widget is in the widget tree
Use click method
If the widget is not in the widget tree
Use offStage method

Dynaimc Branding footer

Dynamic branding footer can be added to widgets that can be added to off-stage widgets.

ℹī¸ This branding footer (brandTag parameter) is currrently available only on offStage method. For click method, it'll be added soon.

Branding footer can be added like this.

                await DavinciCapture.offStage(
                  context: context,
                  const PreviewWidget(),

                  /// Footer can be dynamically added for offStage Widgets
                  brandTag: BrandTagConfiguration(
                    padding: const EdgeInsets.only(left: 20, right: 20),
                    decoration: const BoxDecoration(color: Colors.black),
                    leading: const Text(
                      "Footer dyamically added, Inspired from Reddit",
                      style: TextStyle(fontSize: 14),
                    ),
                    trailing: const Icon(
                      LineIcons.redditAlien,
                      color: Color(0xffFF4500),
                    ),
                  ),
                );


By default the generated image name will be "davinci". But if you wish to change it, you can pass the image name in DavinciCapture.click method.
await DavinciCapture.click(context: context, imageKey, fileName: "Hello");

When the image is captured, you can either open the image preview or get the image in Uint8List.
await DavinciCapture.click(context: context, imageKey, fileName: "Hello", openFilePreview = false, returnImageUint8List = true);

If the captured image is pixelated, calculate the pixel ratio dynamically based on the device and pass it to the DavinciCapture.click method.
double pixelRatio = MediaQuery.of(context).devicePixelRatio;

await DavinciCapture.click(context: context, imageKey, fileName: "Hello", pixelRatio: pixelRatio);

To save the image directly to the device, set saveToDevice flag to true. You can also specify the album name or you can leave it undefined.

await DavinciCapture.click(context: context, imageKey, fileName: "Hello", saveToDevice = true, album: "Davinci", openFilePreview = false);

ℹī¸ All the parameters in the click method is present in offStage method too.

🛎ī¸ Note :

  • If you wish to save the generated images locally, do remember to add necessary permissions in info.plist and AndroidManifest.xml.

Contributors

davinci's People

Contributors

saigkl avatar imgkl avatar mhbdev avatar microprogramer avatar coronon avatar gsoykan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤ī¸ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.