ThingModel.fromJson constructor

ThingModel.fromJson(
  1. Map<String, dynamic> json, {
  2. bool validate = true,
})

Creates a new ThingModel from a json object.

Implementation

factory ThingModel.fromJson(
  Map<String, dynamic> json, {
  // ignore: avoid_unused_constructor_parameters
  bool validate = true,
}) {
  final Set<String> parsedFields = {};

  final title = json.parseField<String>("title", parsedFields);
  final id = json.parseField<String>("id", parsedFields);

  return ThingModel(
    title: title,
    id: id,
  );
}