chunlee-thong / dart-quicktype

Convert JSON to Dart model class. Implement from Quicktype.

Home Page:https://dart-quicktype.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dart QuickType

version: 2.5.1

A custom implemenation of JSON to Dart model class from QuickType.

Netlify Status

Site variation

This project is configure to fit my use case only so the default behavior will be:

  • All fields are final
  • All fields are required
  • Has an option to generate toJSON,copyWith and toString
  • support Equatable and JsonSerialize
  • No freezed or hive

Type setting

When Dart class is generated from json, nullable or non-nullable field are define below.

Type Nullable default value
String setting ""
bool setting false
int setting 0
double setting 0
Array never []
Object always null
DateTime always null
  • Array can never be null
  • Object and DateTime always nullable
  • Other types can configure with checkbox setting

Customize for your use case

  • edit Dart's quicktype config in custom_dart_renderer.ts
  • run npm run build to build from ts to vanilla js
  • test your change in index.html

About

Convert JSON to Dart model class. Implement from Quicktype.

https://dart-quicktype.netlify.app/


Languages

Language:TypeScript 73.2%Language:HTML 11.7%Language:JavaScript 6.6%Language:Dart 6.4%Language:CSS 2.1%