dart-lang / code_builder

A fluent API for generating valid Dart source code
https://pub.dev/packages/code_builder
BSD 3-Clause "New" or "Revised" License
423 stars 66 forks source link

Is it possible to generate a Library object from string data? #459

Closed hasimyerlikaya closed 1 month ago

hasimyerlikaya commented 1 month ago

Hi, I want to read a dart file and create a different file from it. I use code_builder to create the new file. I need variables and their values in a class of type string that I read from the directory. Is it possible to create a Library object from a string or is there a method you can suggest?

Thanks for your help.

This is my file that I need to parse.

import 'package:lang_generator/lang_generator.dart';

@AppLangSource()
class AppLanguage implements IAppLanguage {
  @override
  List<AppLocale> appLocales = [
    AppLocale(language: "tr", country: "TR"),
    AppLocale(language: "en", country: "US"),
  ];
}