Giter Club home page Giter Club logo

easy_dsl's Introduction

EasyDSL: Streamlining Flutter UI Development (WIP)

Introduction

EasyDSL is a Dart package that enhances Flutter UI development by introducing the concept of Domain-Specific Language (DSL). Drawing inspiration from the simplicity of TailwindCSS, EasyDSL enables Flutter developers to use DSL strings to generate Flutter widgets, greatly simplifying the creation of complex user interfaces.

The project is currently under heavy development. Many Tailwind properties are yet to be adapted. Due to the differences between Flutter and the web, not all Tailwind classes will be supported. Additionally, some unique classes will be incorporated.

Features

  • Offers a development experience akin to Tailwind CSS
  • Relies on code generation, ensuring zero runtime cost
  • Continuous development to expand DSL features

Installation

Add these dependencies to pubspec.yaml.

dependencies:
  easy_dsl: latest

dev_dependencies:
  build_runner: ^2.4.0
  easy_dsl_gen: latest

Usage

You must initially set the Widget's name as Div.

// div.dart
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:easy_dsl/easy_dsl.dart';

part 'div.easy.g.dart';

@EasyDSL()
class Div extends $Div {
  const Div({super.key, required super.className, super.children})
      : super(option: const EasyOption.empty());
}

Next, include the following in your build.yaml file:

targets:
  $default:
    builders:
      easy_dsl_gen|easy_gen:
        generate_for:
          - lib/**.dart

Finally, you can use the code in your project as illustrated below:

@override
Widget build(BuildContext context) {
  const className = "items-center bg-black";

  return const Div(
    className: className,
    children: [
      Div(
        className: "bg-red-500 pt-[10] px-[100] py-[20]",
        children: [
          Div(
            className: "p-10 bg-gray-400",
            children: [Text('This is'), Text('EasyDSL')],
          ),
          SizedBox(height: 20),
          Div(
            className: "flex items-center p-[10] bg-gray-500",
            children: [Text('Hello World')],
          ),
        ],
      ),
    ],
  );
}

Note: The value of className must be a string literal or a constant to be resolved at compile time.

Running the code generator

Once you have modified the code related to EasyDSL, you should execute the following command to generate the missing .easy.g.dart generated dart files.

dart run build_runner build

Alternatively, you can execute the following command to continuously monitor file changes.

dart run build_runner watch

Contributing

Contributions to EasyDSL are highly encouraged! If you have suggestions or code contributions, please feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

easy_dsl's People

Contributors

zzzgydi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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