Skip to content

Commit 3fbc810

Browse files
committed
eng: deprecate FieldSerializable#nullable #520
1 parent fe0c05b commit 3fbc810

File tree

31 files changed

+80
-46
lines changed

31 files changed

+80
-46
lines changed

docs/data/fields.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ As providers are ultimately responsible for converting raw data into model data,
1515
| `ignore:` | Do not deserialize (from) or serialize (to) this field to a provider | `@Rest(ignore: true)` |
1616
| `name:` | Stored key for this field according to the provider. In SQLite, for example, this would be the column name. | `@Sqlite(name: "address_2")` |
1717
| `defaultValue:` | Value to use in absence or `null` of the instance. It does not dictate what the Dart model will hold on empty instantiation. **Recommended to use Dart's default constructor assignment instead**. | `@Rest(defaultValue: '[]')` |
18-
| `nullable:` | `null` fields are handled gracefully when serializing and deserializing. | `@Rest(nullable: true)` |
1918
| `fromGenerator` | A stringified function with access to [placeholders](#placeholders); replaces adapter's generated deserialize code for the field. Do not include trailing semicolons or function body wrapping symbols (`{}` or `=>`) in the definition. | `@Rest(fromGenerator: "int.tryParse(%DATA_PROPERTY%.toString())")` |
2019
| `toGenerator` | A stringified function with access to [placeholders](#placeholders); replaces adapter's generated serialize code for the field. Do not include trailing semicolons or function body wrapping symbols (`{}` or `=>`) in the definition. | `@Sqlite(toGenerator: "%INSTANCE_PROPERTY% > 1 ? 1 : 0")` |
2120

packages/brick_build/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## Unreleased
22

3+
## 3.3.1
4+
5+
- Remove `FieldSerializable#nullable` requirement on `deserializerNullableClause`
6+
- Update minimum `brick_core` to `1.4.0`
7+
38
## 3.3.0
49

510
- Add documentation to increase pub.dev score

packages/brick_build/example/file_fields.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'package:analyzer/dart/element/element.dart';
2-
import 'package:brick_core/field_serializable.dart';
32
import 'package:brick_build/generators.dart';
3+
import 'package:brick_core/field_serializable.dart';
44

55
// in a real-world equivalent, this is an annotation
66
class File implements FieldSerializable {
@@ -52,7 +52,7 @@ class _FileSerdesFinder extends AnnotationFinder<File> {
5252
_FileSerdesFinder();
5353

5454
@override
55-
File from(element) {
55+
File from(FieldElement element) {
5656
final obj = objectForField(element);
5757

5858
if (obj == null) {

packages/brick_build/lib/src/serdes_generator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ abstract class SerdesGenerator<FieldAnnotation extends FieldSerializable,
268268
required FieldAnnotation fieldAnnotation,
269269
required String name,
270270
}) =>
271-
fieldAnnotation.nullable && field.type.nullabilitySuffix != NullabilitySuffix.none
271+
field.type.nullabilitySuffix != NullabilitySuffix.none
272272
? "data['$name'] == null ? null :"
273273
: '';
274274

packages/brick_build/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_build
44
issue_tracker: https://github.com/GetDutchie/brick/issues
55
repository: https://github.com/GetDutchie/brick
66

7-
version: 3.3.0
7+
version: 3.3.1
88

99
environment:
1010
sdk: ">=2.18.0 <4.0.0"
1111

1212
dependencies:
1313
analyzer: ">=6.0.0 <7.0.0"
14-
brick_core: ^1.3.0
14+
brick_core: ">=1.4.0 <2.0.0"
1515
build: ^2.3.0
1616
dart_style: ">=2.0.0 <3.0.0"
1717
glob: ">=2.1.0 <3.0.0"

packages/brick_core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
## 1.4.0
4+
5+
- **DEPRECATION** remove `FieldSerializable#nullable`. Builders should evaluate the nullable suffix of the field instead
6+
37
## 1.3.1
48

59
- `const`antize `Where.exactly` and `OrderBy.{desc|asc}`

packages/brick_core/lib/field_serializable.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ abstract class FieldSerializable {
4545

4646
/// When `true`, `null` fields are handled gracefully when serializing and deserializing.
4747
/// For Dart >=2.12, the member type must also be nullable (i.e. `bool?`).
48+
@Deprecated('Use a nullable type instead')
4849
bool get nullable;
4950

5051
/// Manipulates output for the field in the serialize generator.

packages/brick_core/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ homepage: https://github.com/GetDutchie/brick/tree/main/packages/brick_core
44
issue_tracker: https://github.com/GetDutchie/brick/issues
55
repository: https://github.com/GetDutchie/brick
66

7-
version: 1.3.1
7+
version: 1.4.0
88

99
environment:
1010
sdk: ">=3.0.0 <4.0.0"

packages/brick_graphql/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
## 3.3.0
4+
5+
- **DEPRECATION** remove `Graphql#nullable`. Builders should evaluate the nullable suffix of the field instead
6+
37
## 3.2.0
48

59
- **DEPRECATION** `Query(providerArgs: {'context':})` is now `Query(forProviders: [GraphqlProviderQuery(context:)])`

packages/brick_graphql/lib/src/annotations/graphql.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Graphql implements FieldSerializable {
3434
/// This indicates that the payload from GraphQL could be `null` and is not related to
3535
/// Dart nullability. Defaults to `false`.
3636
@override
37+
@Deprecated('Use a nullable type instead')
3738
final bool nullable;
3839

3940
/// Supply subfields that should be requested from the server.
@@ -58,7 +59,7 @@ class Graphql implements FieldSerializable {
5859
bool? ignoreFrom,
5960
bool? ignoreTo,
6061
this.name,
61-
bool? nullable,
62+
@Deprecated('Use a nullable type instead') bool? nullable,
6263
this.subfields,
6364
this.toGenerator,
6465
}) : enumAsString = enumAsString ?? false,

0 commit comments

Comments
 (0)