data_annotation

Creator: coderz1093

Last updated:

0 purchases

data_annotation Image
data_annotation Images

Languages

Categories

Add to Cart

Description:

data annotation

Data annotation is used to transform an abstract class into an immutable data class with data_builder.
Usage #
A simple usage with nullSafety example:
import 'package:data_annotation/data_annotation.dart';

part 'example.data.dart';

enum ExampleEnum { example }

class Model {
Model.fromJson(Map<String, dynamic> json);

Map<String, dynamic> toJson() => {};
}

@data
abstract class ExampleDataClass with _$ExampleDataClass {
const ExampleDataClass._();

const factory ExampleDataClass({
double? field,
String? field1,
int? field2,
bool? field3,
ExampleEnum? field4,
@DataKey('model') Model? field5,
Uri? field6,
BigInt? field7,
DateTime? field8,
Duration? field9,
@DataKey('models') List<Model>? field10,
@DataKey('modelByKey') Map<String, Model>? field11,
}) = _ExampleDataClass;

factory ExampleDataClass.fromJson(Map<String, dynamic> json) =
_ExampleDataClass.fromJson;

Map<String, dynamic> toJson();
}
copied to clipboard
A simple usage without nullSafety example:
import 'package:data_annotation/data_annotation.dart';

part 'example.data.dart';

enum ExampleEnum { example }

class Model {
Model.fromJson(Map<String, dynamic> json);

Map<String, dynamic> toJson() => {};
}

@data
abstract class ExampleDataClass with _$ExampleDataClass {
const ExampleDataClass._();

const factory ExampleDataClass({
double field,
String field1,
int field2,
bool field3,
ExampleEnum field4,
@DataKey('model') Model field5,
Uri field6,
BigInt field7,
DateTime field8,
Duration field9,
@DataKey('models') List<Model> field10,
@DataKey('modelByKey') Map<String, Model> field11,
}) = _ExampleDataClass;

factory ExampleDataClass.fromJson(Map<String, dynamic> json) =
_ExampleDataClass.fromJson;

Map<String, dynamic> toJson();
}
copied to clipboard
Features and bugs #
Please file feature requests and bugs at the issue tracker.

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.