Skip to content

Commit

Permalink
Replace deprecated JsonKey annotation for hashCode and copyWith (rr…
Browse files Browse the repository at this point in the history
  • Loading branch information
lrsvmb authored Jul 9, 2024
1 parent b2280e9 commit 280a863
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 64 deletions.
12 changes: 6 additions & 6 deletions benchmarks/lib/src/copy_with.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ final _privateConstructorUsedError = UnsupportedError(
mixin _$Model {
int get counter => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$ModelCopyWith<Model> get copyWith => throw _privateConstructorUsedError;
}

Expand Down Expand Up @@ -110,7 +110,7 @@ class _$ModelImpl implements _Model {
@override
int get hashCode => Object.hash(runtimeType, counter);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ModelImplCopyWith<_$ModelImpl> get copyWith =>
Expand All @@ -123,7 +123,7 @@ abstract class _Model implements Model {
@override
int get counter;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ModelImplCopyWith<_$ModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Expand All @@ -132,7 +132,7 @@ abstract class _Model implements Model {
mixin _$ModelWrapper {
Model get model => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$ModelWrapperCopyWith<ModelWrapper> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -240,7 +240,7 @@ class _$ModelWrapperImpl implements _ModelWrapper {
@override
int get hashCode => Object.hash(runtimeType, model);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ModelWrapperImplCopyWith<_$ModelWrapperImpl> get copyWith =>
Expand All @@ -253,7 +253,7 @@ abstract class _ModelWrapper implements ModelWrapper {
@override
Model get model;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ModelWrapperImplCopyWith<_$ModelWrapperImpl> get copyWith =>
throw _privateConstructorUsedError;
}
6 changes: 3 additions & 3 deletions benchmarks/lib/src/equal.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mixin _$ModelWithList {
List<int> get someList => throw _privateConstructorUsedError;
int get counter => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$ModelWithListCopyWith<ModelWithList> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ class _$ModelWithListImpl implements _ModelWithList {
int get hashCode => Object.hash(
runtimeType, const DeepCollectionEquality().hash(_someList), counter);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ModelWithListImplCopyWith<_$ModelWithListImpl> get copyWith =>
Expand All @@ -154,7 +154,7 @@ abstract class _ModelWithList implements ModelWithList {
@override
int get counter;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ModelWithListImplCopyWith<_$ModelWithListImpl> get copyWith =>
throw _privateConstructorUsedError;
}
36 changes: 18 additions & 18 deletions packages/_internal/lib/models.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mixin _$DeepCloneableProperty {
GenericsParameterTemplate get genericParameters =>
throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$DeepCloneablePropertyCopyWith<DeepCloneableProperty> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -192,7 +192,7 @@ class _$DeepCloneablePropertyImpl implements _DeepCloneableProperty {
int get hashCode => Object.hash(
runtimeType, name, typeName, type, nullable, genericParameters);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DeepCloneablePropertyImplCopyWith<_$DeepCloneablePropertyImpl>
Expand Down Expand Up @@ -220,7 +220,7 @@ abstract class _DeepCloneableProperty implements DeepCloneableProperty {
@override
GenericsParameterTemplate get genericParameters;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DeepCloneablePropertyImplCopyWith<_$DeepCloneablePropertyImpl>
get copyWith => throw _privateConstructorUsedError;
}
Expand All @@ -245,7 +245,7 @@ mixin _$ConstructorDetails {
throw _privateConstructorUsedError;
List<AssertTemplate> get asserts => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$ConstructorDetailsCopyWith<ConstructorDetails> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -658,7 +658,7 @@ class _$ConstructorDetailsImpl extends _ConstructorDetails {
const DeepCollectionEquality().hash(_cloneableProperties),
const DeepCollectionEquality().hash(_asserts));

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$ConstructorDetailsImplCopyWith<_$ConstructorDetailsImpl> get copyWith =>
Expand Down Expand Up @@ -719,7 +719,7 @@ abstract class _ConstructorDetails extends ConstructorDetails {
@override
List<AssertTemplate> get asserts;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$ConstructorDetailsImplCopyWith<_$ConstructorDetailsImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Expand All @@ -730,7 +730,7 @@ mixin _$MapConfig {
bool get mapOrNull => throw _privateConstructorUsedError;
bool get maybeMap => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$MapConfigCopyWith<MapConfig> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -853,7 +853,7 @@ class _$MapConfigImpl implements _MapConfig {
@override
int get hashCode => Object.hash(runtimeType, map, mapOrNull, maybeMap);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$MapConfigImplCopyWith<_$MapConfigImpl> get copyWith =>
Expand All @@ -873,7 +873,7 @@ abstract class _MapConfig implements MapConfig {
@override
bool get maybeMap;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$MapConfigImplCopyWith<_$MapConfigImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Expand All @@ -884,7 +884,7 @@ mixin _$WhenConfig {
bool get whenOrNull => throw _privateConstructorUsedError;
bool get maybeWhen => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$WhenConfigCopyWith<WhenConfig> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -1008,7 +1008,7 @@ class _$WhenConfigImpl implements _WhenConfig {
@override
int get hashCode => Object.hash(runtimeType, when, whenOrNull, maybeWhen);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$WhenConfigImplCopyWith<_$WhenConfigImpl> get copyWith =>
Expand All @@ -1028,7 +1028,7 @@ abstract class _WhenConfig implements WhenConfig {
@override
bool get maybeWhen;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$WhenConfigImplCopyWith<_$WhenConfigImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Expand All @@ -1055,7 +1055,7 @@ mixin _$Data {
bool get shouldUseExtends => throw _privateConstructorUsedError;
bool get genericArgumentFactories => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$DataCopyWith<Data> get copyWith => throw _privateConstructorUsedError;
}

Expand Down Expand Up @@ -1464,7 +1464,7 @@ class _$DataImpl implements _Data {
shouldUseExtends,
genericArgumentFactories);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$DataImplCopyWith<_$DataImpl> get copyWith =>
Expand Down Expand Up @@ -1523,7 +1523,7 @@ abstract class _Data implements Data {
@override
bool get genericArgumentFactories;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$DataImplCopyWith<_$DataImpl> get copyWith =>
throw _privateConstructorUsedError;
}
Expand All @@ -1533,7 +1533,7 @@ mixin _$GlobalData {
bool get hasJson => throw _privateConstructorUsedError;
bool get hasDiagnostics => throw _privateConstructorUsedError;

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
$GlobalDataCopyWith<GlobalData> get copyWith =>
throw _privateConstructorUsedError;
}
Expand Down Expand Up @@ -1642,7 +1642,7 @@ class _$GlobalDataImpl implements _GlobalData {
@override
int get hashCode => Object.hash(runtimeType, hasJson, hasDiagnostics);

@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$GlobalDataImplCopyWith<_$GlobalDataImpl> get copyWith =>
Expand All @@ -1659,7 +1659,7 @@ abstract class _GlobalData implements GlobalData {
@override
bool get hasDiagnostics;
@override
@JsonKey(ignore: true)
@JsonKey(includeFromJson: false, includeToJson: false)
_$$GlobalDataImplCopyWith<_$GlobalDataImpl> get copyWith =>
throw _privateConstructorUsedError;
}
6 changes: 6 additions & 0 deletions packages/freezed/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## Unreleased patch

- Stop using `JsonKey(ignore: true)` in favour of `JsonKey(includeFromJson: false, includeToJson: false)`
(thanks to @lrsvmb)
- Require json_annotation ^6.8.0

## 2.5.4 - 2024-07-02

- Require Dart >=3.0.0
Expand Down
Loading

0 comments on commit 280a863

Please sign in to comment.