dslgen 0.1.3
dslgen: ^0.1.3 copied to clipboard

A DSL generation command-line application.

Dart Code Conversion To DSL Json #

A small command line utility to generate a DSL json from dart code.

Examples #

Below is a dart file include function commoned with ”// @yingzi“

// @yingzi
Widget testNetImage() {
  return Scaffold(
    appBar: AppBar(
      title: Text('Container属性测试'),
    ),
    body: Container(
      width: 375,
      height: 600,
      color: Color(0xff11ccab),
      alignment: Alignment.centerLeft,
      padding: EdgeInsets.fromLTRB(3, 6, 9, 13),
      child: Image.network(
          'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=333697138,3478361041&fm=26&gp=0.jpg'),
    ),
  );
}

Generated json:

{
    "widgetName": "Scaffold",
    "props": {
        "appBar": {
            "widgetName": "AppBar",
            "props": {
                "title": {
                    "widgetName": "Text",
                    "props": {
                        "data": "Container属性测试"
                    }
                }
            }
        },
        "body": {
            "widgetName": "Container",
            "props": {
                "width": "375",
                "height": "600",
                "color": "0xff11ccab",
                "alignment": "centerLeft",
                "padding": "[3,6,9,13]",
                "child": {
                    "widgetName": "Image",
                    "props": {
                        "type": "network",
                        "src": "https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=333697138,3478361041&fm=26&gp=0.jpg"
                    }
                }
            }
        }
    }
}

Installation #

Install from pub:

pub gloabl activate dslgen

Usage #

dslgen <filePaht>

See --help for more options,including ways to choose diffrent json formmatter

Visualization Tool #

You can use the visualization tool AST_Tool image

What Is The Use #

The dsl json can rendering to Flutter widget by the package flutter_dynamic.

YZDynamic.buildPage(context, dslJson);

Then it become easy to build a dynamic flutter page.

0
likes
60
pub points
0%
popularity

Publisher

Unknown

A DSL generation command-line application.

Homepage

Documentation

API reference

License

BSD (LICENSE)

Dependencies

analyzer, args

More

Packages that depend on dslgen