Coder Social home page Coder Social logo

apach3q / stack_art_board Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 2.0 1.21 MB

A Flutter package consisting of stacks that allows adding any widgets, and enables editing, deleting, and changing the order of layers.

License: Other

Java 0.61% Kotlin 0.13% Swift 1.26% Objective-C 0.70% Dart 48.22% CMake 20.33% C++ 24.61% C 1.55% HTML 2.00% Shell 0.60%

stack_art_board's Introduction

Stack Art Board

A Flutter package consisting of stacks that allows adding any widgets, and enables editing, deleting, and changing the order of layers.

pub package GitHub stars GitHub forks


For a more throughout example see the example.

2023-07-11.08.53.17.mov

How to Use

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  stack_art_board: <latest_version>

In your library add the following import:

import 'package:stack_art_board/stack_art_board.dart';

For help getting started with Flutter, view the online documentation.

Initialize a StackArtboard

import 'package:stack_art_board/stack_art_board.dart';

final StackArtBoardController controller = StackArtBoardController();

StackArtBoard(
    stackArtBoardKey: UniqueKey(),
    controller: controller,
    artBoardConfig: ArtBoardConfig(
    containerSize: const Size(300, 300),
    artBoardSize: const Size(3000, 3000),
    toolIconWidth: 20,
    borderWidth: 5,
    borderColor: Colors.black,
    rotateWidget: Container(color: Colors.orange),
    deleteWidget: Container(color: Colors.purple),
    ),
    background: Container(color: Colors.green),
),

Add a custom Widget

controller.add(
    CustomCanvasItem(
        child: Container(
            color: Colors.red,
            child: const Center(
                child: Text('text'),
            ),
        ),
        canvasConfig: CanvasConfig(
            size: const Size(600, 600),
            transform: Matrix4.identity(),
            allowUserInteraction: true,
        ),
    ),
);

Add an Image widget with the ability to penetrate click events through transparent areas of the image.

final ByteData data = await rootBundle.load('assets/image.png');
final imageBytes = data.buffer.asUint8List();
final image = img_lib.decodeImage(imageBytes);
if (image == null) return;
controller.add(
    TransparentBgImageCanvasItem(
        image: image,
        imageBytes: imageBytes,
        canvasConfig: CanvasConfig(
            size: Size(image.width.toDouble(), image.height.toDouble()),
            transform: Matrix4.identity(),
            allowUserInteraction: true,
        ),
    ),
);

All canvas operations

void add<T extends CanvasItem>(T item)
void insert<T extends CanvasItem>(T item, int index)
void remove(Key key)
void removeExcept(Key key)
bool contain(Key key)
void clear()
void moveToTop()
void moveToBottom()
void move(int oldIndex, int newIndex)
void reset()
void dispose()

Sponsoring

I'm working on my packages on my free-time, but I don't have as much time as I would. If this package or any other package I created is helping you, please consider to sponsor me so that I can take time to read the issues, fix bugs, merge pull requests and add features to these packages.


Contributions

Feel free to contribute to this project.

If you find a bug or want a feature, but don't know how to fix/implement it, please fill an issue.
If you fixed a bug or implemented a feature, please send a pull request.

stack_art_board's People

Contributors

guo8a avatar

Stargazers

idaretobe avatar  avatar Jiaohang avatar Link avatar

Watchers

 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.