Input JSON Data
Dart Model Code
Tool Guide & Dart (Flutter) Data Model Info
Tool Features
- Fully Automatic Manual Parse: Deeply traverses and parses nested objects and arrays, generating absolutely safe
fromJsonandtoJsonfactory methods that do not rely on any third-party libraries. This is especially suitable for small to medium-sized projects or scenarios where build tools are not desired. - json_serializable Support: For large Flutter projects using
json_serializable, the tool will automatically add thepartdirective and@JsonKeyannotations, so you only need to runbuild_runner. - Sound Null Safety: Fully supports sound null safety introduced in Dart 2.12. When enabled, all properties will have a
?nullable marker attached, preventing dirty interface data from causing red screen crashes at runtime.
Factory Constructors in Dart
- factory Keyword: In Dart,
factory ClassName.fromJson(...)is a very classic way to instantiate JSON. Factory constructors allow us to perform complex parsing and judgments in the method body and finally return a new instance (or an instance from the cache). - final Modifier: In Flutter state management (especially with Provider or Bloc), data models should be Immutable. Therefore, the tool uses the
finalmodifier for all fields by default.
