freezer 0.6.1 copy "freezer: ^0.6.1" to clipboard
freezer: ^0.6.1 copied to clipboard

discontinued

Provides the easiest and most productive automatic generation of model objects from JSON files.

example/README.md

Just Execute dart run freezer:main #

From #

{
  "shop": {
    "name.!required": "My Fancy Shop",
    "products.!as:product.!name:my_products": [
      {
        "name": "Chocolate",
        "price": 5.99
      },
      {
        "name": "Gummy",
        "price": 8.99
      }
    ],
    "location": [-122.4194, 37.7749],
    "closed": false,
    "$name": "This is a comment for name field.",
    "$products": "This is a comment for product field.",
    "$$products": "This is a comment for product object."
  }
}

To #

// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: invalid_annotation_target

import 'package:freezed_annotation/freezed_annotation.dart';

import 'product.dart';

part 'shop.freezed.dart';
part 'shop.g.dart';

// **************************************************************************
// FreezerGenerator
// **************************************************************************

@freezed
class Shop with _$Shop {
  const factory Shop({
    /// This is a comment for name field.
    required String name,

    /// This is a comment for product field.
    @JsonKey(name: 'products') List<Product>? myProducts,
    List<double>? location,
    bool? closed,
  }) = _Shop;

  /// Returns [Shop] based on [json].
  factory Shop.fromJson(Map<String, Object?> json) => _$ShopFromJson(json);
}
// GENERATED CODE - DO NOT MODIFY BY HAND

import 'package:freezed_annotation/freezed_annotation.dart';

part 'product.freezed.dart';
part 'product.g.dart';

// **************************************************************************
// FreezerGenerator
// **************************************************************************

/// This is a comment for product object.
@freezed
class Product with _$Product {
  const factory Product({
    String? name,
    double? price,
  }) = _Product;

  /// Returns [Product] based on [json].
  factory Product.fromJson(Map<String, Object?> json) =>
      _$ProductFromJson(json);
}
24
likes
150
pub points
64%
popularity

Publisher

verified publishershinyakato.dev

Provides the easiest and most productive automatic generation of model objects from JSON files.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

build_runner, dart_style

More

Packages that depend on freezer