在dart中将compilationUnit对象转换为json

时间:2017-07-20 12:58:12

标签: json dart abstract-syntax-tree dart-analyzer

无论如何将compilationUnit对象转换为json?

String src = """
import 'package:flutter/material.dart';

void main() {
   runApp(new MyApp());
}
@Entity()
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
 return new Container(
    decoration: new BoxDecoration(color: Colors.cyan),
    child: (new Center(child: new Text("Hello"))));

 }
}""";
var ast = parseCompilationUnit(src, parseFunctionBodies: true);

我正在使用此方法获取dart代码的ast,我希望它将其转换为json对象。

0 个答案:

没有答案