0 purchases
dslgen
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'),
),
);
}
copied to clipboard
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"
}
}
}
}
}
}
copied to clipboard
Installation #
Install from pub:
pub gloabl activate dslgen
copied to clipboard
Usage #
dslgen <filePaht>
copied to clipboard
See --help for more options,including ways to choose diffrent json formmatter
Visualization Tool #
You can use the visualization tool
AST_Tool
What Is The Use #
The dsl json can rendering to Flutter widget by the package flutter_dynamic.
YZDynamic.buildPage(context, dslJson);
copied to clipboard
Then it become easy to build a dynamic flutter page.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.