Skip to main content

json_to_dart_library 0.0.5 copy "json_to_dart_library: ^0.0.5" to clipboard
json_to_dart_library: ^0.0.5 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.

1
likes
0
points
54
downloads

Publisher

unverified uploader

Weekly Downloads

The library to convert json to dart code

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

compute, dart_style, dartx, equatable, get_it, intl

More

Packages that depend on json_to_dart_library