dart_json_mapper_built

Creator: coderz1093

Last updated:

0 purchases

dart_json_mapper_built Image
dart_json_mapper_built Images

Languages

Categories

Add to Cart

Description:

dart json mapper built

This is a dart-json-mapper complementary package provides support for https://pub.dev/packages/built_collection types in order to serialize / deserialize them from / to JSON.
Basic setup #
Beforehand please consult with basic setup section from dart-json-mapper package.
Please add the following dependencies to your pubspec.yaml:
dependencies:
dart_json_mapper:
dart_json_mapper_built:
dev_dependencies:
build_runner:
copied to clipboard
Usage example
lib/main.dart
import 'package:built_collection/built_collection.dart';
import 'package:dart_json_mapper/dart_json_mapper.dart' show JsonMapper, jsonSerializable;
import 'package:dart_json_mapper_built/dart_json_mapper_built.dart' show builtAdapter;

import 'main.mapper.g.dart' show initializeJsonMapper;

@jsonSerializable
class ImmutableClass {
final BuiltList<int> list;

const ImmutableClass(this.list);
}

void main() {
initializeJsonMapper(adapters: [builtAdapter]);

print(JsonMapper.serialize(
ImmutableClass(BuiltList.of([1, 2, 3]))
));
}
copied to clipboard
output:
{
"list": [1,2,3]
}
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.