2.2.2 add idioms
This commit is contained in:
parent
d97feaa899
commit
532301432a
4 changed files with 27 additions and 23 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
# 2.2.2
|
||||||
|
* Add `HasAlias`, `DefaultsTo`, `nullable` idioms.
|
||||||
|
* `isNullable` defaults to `false` now.
|
||||||
|
|
||||||
# 2.2.1
|
# 2.2.1
|
||||||
* Add `serializesTo`.
|
* Add `serializesTo`.
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,23 @@
|
||||||
export 'package:quiver_hashcode/hashcode.dart' show hashObjects;
|
export 'package:quiver_hashcode/hashcode.dart' show hashObjects;
|
||||||
|
|
||||||
/// Excludes a field from being excluded.
|
/// Excludes a field from being excluded.
|
||||||
@deprecated
|
class Exclude extends SerializableField {
|
||||||
class Exclude {
|
const Exclude({bool canDeserialize: false, bool canSerialize: false})
|
||||||
final bool canSerialize;
|
: super(canDeserialize: canDeserialize, canSerialize: canSerialize);
|
||||||
|
|
||||||
final bool canDeserialize;
|
|
||||||
|
|
||||||
const Exclude({this.canDeserialize: false, this.canSerialize: false});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@deprecated
|
const SerializableField nullable = const SerializableField(isNullable: true);
|
||||||
// ignore: deprecated_member_use
|
|
||||||
const Exclude exclude = const Exclude();
|
const Exclude exclude = const Exclude();
|
||||||
|
|
||||||
@deprecated
|
/// Shorthand for [SerializableField].
|
||||||
|
class DefaultsTo extends SerializableField {
|
||||||
|
const DefaultsTo(value) : super(defaultValue: value);
|
||||||
|
}
|
||||||
|
|
||||||
/// Prefer [SerializableField] instead.
|
/// Shorthand for [SerializableField].
|
||||||
class DefaultValue {
|
class HasAlias extends SerializableField {
|
||||||
final value;
|
const HasAlias(String name) : super(alias: name);
|
||||||
|
|
||||||
const DefaultValue(this.value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Attaches options to a field.
|
/// Attaches options to a field.
|
||||||
|
@ -66,7 +63,7 @@ class SerializableField {
|
||||||
this.serializer,
|
this.serializer,
|
||||||
this.deserializer,
|
this.deserializer,
|
||||||
this.errorMessage,
|
this.errorMessage,
|
||||||
this.isNullable: true,
|
this.isNullable: false,
|
||||||
this.exclude: false,
|
this.exclude: false,
|
||||||
this.canDeserialize: false,
|
this.canDeserialize: false,
|
||||||
this.canSerialize: false,
|
this.canSerialize: false,
|
||||||
|
@ -122,6 +119,13 @@ abstract class Serializers {
|
||||||
static const int typescript = 2;
|
static const int typescript = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@deprecated
|
||||||
|
class DefaultValue {
|
||||||
|
final value;
|
||||||
|
|
||||||
|
const DefaultValue(this.value);
|
||||||
|
}
|
||||||
|
|
||||||
@deprecated
|
@deprecated
|
||||||
|
|
||||||
/// Prefer [SerializableField] instead.
|
/// Prefer [SerializableField] instead.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_serialize
|
name: angel_serialize
|
||||||
version: 2.2.1+2
|
version: 2.2.2
|
||||||
description: Static annotations powering Angel model serialization. Combine with angel_serialize_generator for flexible modeling.
|
description: Static annotations powering Angel model serialization. Combine with angel_serialize_generator for flexible modeling.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/serialize
|
homepage: https://github.com/angel-dart/serialize
|
||||||
|
|
|
@ -32,12 +32,8 @@ const TypeChecker generatedSerializableTypeChecker =
|
||||||
final Map<String, BuildContext> _cache = {};
|
final Map<String, BuildContext> _cache = {};
|
||||||
|
|
||||||
/// Create a [BuildContext].
|
/// Create a [BuildContext].
|
||||||
Future<BuildContext> buildContext(
|
Future<BuildContext> buildContext(ClassElement clazz, ConstantReader annotation,
|
||||||
ClassElement clazz,
|
BuildStep buildStep, Resolver resolver, bool autoSnakeCaseNames,
|
||||||
ConstantReader annotation,
|
|
||||||
BuildStep buildStep,
|
|
||||||
Resolver resolver,
|
|
||||||
bool autoSnakeCaseNames,
|
|
||||||
{bool heedExclude: true}) async {
|
{bool heedExclude: true}) async {
|
||||||
var id = clazz.location.components.join('-');
|
var id = clazz.location.components.join('-');
|
||||||
if (_cache.containsKey(id)) {
|
if (_cache.containsKey(id)) {
|
||||||
|
|
Loading…
Reference in a new issue