json_to_dart_library 0.0.7 copy "json_to_dart_library: ^0.0.7" to clipboard
json_to_dart_library: ^0.0.7 copied to clipboard

The library to convert json to dart code

The library to convert json to dart code #

The library for https://github.com/fluttercandies/JsonToDart/Flutter/json_to_dart

simple used #

Future<void> main(List<String> args) async {
  DartObject? dartObject = await jsonToDartController.jsonToDartObject(
    json: '''{"data":[{"a":1}],"msg":"s","code":0}''',
  );
  var errors = jsonToDartController.getErrors();
  if (errors.isNotEmpty) {
    print('Errors found:');
    for (var error in errors) {
      print(error);
    }
    return;
  }

  if (dartObject != null) {
    var dartCode = jsonToDartController.generateDartCode(dartObject);
    File('output.dart').writeAsStringSync(dartCode!);
    print('Dart code generated successfully:');
  }
}

custom #

you can define the config and DartObject/DartProperty to generate your own dart style code.

you can see bin/custom.dart to see more info.

0
likes
110
points
30
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

The library to convert json to dart code

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

compute, dart_style, dartx, equatable, get_it, intl, json_schema

More

Packages that depend on json_to_dart_library