google / google/built_value.dart
BuiltValue deprecation
- Dominant language
- Dart
- Stars
- 886
- Forks
- 195
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 4
Description
BuiltValue should be deprecated, because Freezed does the same stuff and more, and much easier and more concise.
It was a good choice in 2018, but now it's undesirable for beginners to drag this outdated package into the modern projects.
BuiltValue has a strange ugly syntax with numerous getters and annotations:
```dart
abstract class Person implements Built {
static Serializer get serializer => _$personSerializer;
// Can never be null.
int get id;
@nullable
int get age;
@nullable
@BuiltValueField(wireName: 'first_name')
String get firstName;
@nullable
BuiltList get hobbies;
Person._();
factory Person([void Function(PersonBuilder) updates]) = _$Person;
}
```
While Freezed syntax is intuitive and much less verbose:
```dart
@freezed
class Person with _$Person {
const factory Person({
required String firstName,
required String lastName,
required int age,
}) = _Person;
}
```
Also it's great for BLoC states declaration:
```dart
@freezed
class Union with _$Union {
const factory Union.data(int value) = Data;
const factory Union.loading() = Loading;
const factory Union.error([String? message]) = Error;
}
```
BuiltValue also has a cumbersome copying through the Builder pattern:
```dart
var structuredData = new Account((b) => b
..user.update((b) => b
..name = 'John Smith')
..credentials.phone.update((b) => b
..country = Country.us
..number = '555 01234 567')
..node.left.left.left.account.update((b) => b
..user.name = 'John Smith II'
..user.nickname = 'Is lost in a tree')
..node.left.right.right.account.update((b) => b
..user.name = 'John Smith III'));
```
While Freezed supports a familiar copyWith method
```dart
newCompany = company.copyWith.director(name: 'John Doe');
```
You could continue supporting it, but I suggest you putting the statement "Prefer choosing Freezed" on a main page.
Contributor guide
Assessment
This issue has not been assessed yet.