Code Monkey home page Code Monkey logo

flutter_drag_drop_match_widget's Introduction

This package makes creating drag and drop UI easier. If you are planning to make an app where you need to drag & drop the matching component, this package would be helpful for you.

Features

Create drag and drop UI's with few lines of code Useful for games and other interactive apps

Methods

DragDropItem This is the parent class. It accepts various parameters.

key: value: dragChild: dropChild: iconData:

Except for key and value , all fields are optional. If no dragChild/dropChild is provided, you'll get a Text widget as your drag/drop components.

DragDropWidget is the base class where you provide reference to your drag drop items. It accepts 3 parameters. items: Collection of DragDropItem. onMatched: If the dragged item matched with dropped item. onMismatched : if the dragged item is not matched with drop items.

Getting started

Add the packages to pubspec and get started.

drag_drop_match_widget: ^0.0.1

Usage

final items = [
  DragDropItem(
      key: "apple",
      value: "apple",
      dragChild: Text(
        "APPLE",
        style: TextStyle(fontSize: 30),
      ),
      dropChild: Text(
        "๐ŸŽ",
        style: TextStyle(fontSize: 50),
      ),
      iconData: Icons.one_k),
  DragDropItem(
      key: "ball",
      value: "Ball",
      dragChild: Text(
        "BALL",
        style: TextStyle(fontSize: 30),
      ),
      dropChild: Text(
        "โšฝ",
        style: TextStyle(fontSize: 50),
      ),
      iconData: Icons.one_k),
  DragDropItem(
      key: "cat",
      value: "Cat",
      dragChild: Text(
        "CAT",
        style: TextStyle(fontSize: 30),
      ),
      dropChild: Text(
        "๐Ÿ˜บ",
        style: TextStyle(fontSize: 50),
      ),
      iconData: Icons.one_k)
];

Use the widget as,

DragDropWidget(
              items: items,
              //on  Matched event
              onMatched: (DragDropItem? item) {
                score += 10;
                setState(() {});
                matched.add(item);
                
                if (matched.length == items.length) {
                  print("GAME OVER");
                }
              },
              //on mismatched event
              onMisMatched: (DragDropItem? item) {
                print("Mismatched");
                print(item);
              });

Additional information

To find more information about the package visit https://github.com/sabine33/flutter_drag_drop_match_widget

flutter_drag_drop_match_widget's People

Contributors

sabine33 avatar

Stargazers

 avatar Grigory Vodyanov avatar  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.