Fix const bug2
This commit is contained in:
parent
dfb4957bf7
commit
7768b906b7
5 changed files with 13 additions and 2 deletions
|
@ -1,3 +1,7 @@
|
|||
# 2.0.8+2
|
||||
* Better discern when custom methods disqualify classes
|
||||
from `const` protection.
|
||||
|
||||
# 2.0.8+1
|
||||
* Fix generation of `const` constructors with iterables.
|
||||
|
||||
|
|
|
@ -68,7 +68,8 @@ class JsonModelGenerator extends GeneratorForAnnotation<Serializable> {
|
|||
bool shouldBeConstant(BuildContext ctx) {
|
||||
// Check if all fields are without a getter
|
||||
return !isAssignableToModel(ctx.clazz.type) &&
|
||||
ctx.clazz.fields.every((f) => f.getter == null || f.setter == null);
|
||||
ctx.clazz.fields.every((f) =>
|
||||
f.getter?.isAbstract != false && f.setter?.isAbstract != false);
|
||||
}
|
||||
|
||||
/// Generate a constructor with named parameters.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_serialize_generator
|
||||
version: 2.0.8+1
|
||||
version: 2.0.8+2
|
||||
description: Model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/serialize
|
||||
|
|
|
@ -91,6 +91,10 @@ main() {
|
|||
expect(library.copyWith(), library);
|
||||
});
|
||||
|
||||
test('custom method', () {
|
||||
expect(jkRowling.customMethod, 'hey!');
|
||||
});
|
||||
|
||||
test('required fields fromMap', () {
|
||||
expect(() => AuthorSerializer.fromMap({}), throwsFormatException);
|
||||
});
|
||||
|
|
|
@ -15,6 +15,8 @@ abstract class _Author extends Model {
|
|||
@required
|
||||
String get name;
|
||||
|
||||
String get customMethod => 'hey!';
|
||||
|
||||
@Required('Custom message for missing `age`')
|
||||
int get age;
|
||||
|
||||
|
|
Loading…
Reference in a new issue