2

Is there anyway to convert the compilationUnit object into the 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);

I am using this method to get the ast of the dart code and i want it to convert it into json object.

Rishab Jain
  • 269
  • 4
  • 16

0 Answers0