mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
code sharing sample: flat package directory (#1486)
This commit is contained in:
19
code_sharing/shared/lib/src/models.dart
Normal file
19
code_sharing/shared/lib/src/models.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'models.freezed.dart';
|
||||
part 'models.g.dart';
|
||||
|
||||
@Freezed()
|
||||
class Increment with _$Increment {
|
||||
const factory Increment({required int by}) = _Increment;
|
||||
|
||||
factory Increment.fromJson(Map<String, dynamic> json) =>
|
||||
_$IncrementFromJson(json);
|
||||
}
|
||||
|
||||
@Freezed()
|
||||
class Count with _$Count {
|
||||
const factory Count(int value) = _Count;
|
||||
|
||||
factory Count.fromJson(Map<String, dynamic> json) => _$CountFromJson(json);
|
||||
}
|
||||
271
code_sharing/shared/lib/src/models.freezed.dart
Normal file
271
code_sharing/shared/lib/src/models.freezed.dart
Normal file
@@ -0,0 +1,271 @@
|
||||
// coverage:ignore-file
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
// ignore_for_file: type=lint
|
||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
||||
|
||||
part of 'models.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// FreezedGenerator
|
||||
// **************************************************************************
|
||||
|
||||
T _$identity<T>(T value) => value;
|
||||
|
||||
final _privateConstructorUsedError = UnsupportedError(
|
||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||
|
||||
Increment _$IncrementFromJson(Map<String, dynamic> json) {
|
||||
return _Increment.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Increment {
|
||||
int get by => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$IncrementCopyWith<Increment> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $IncrementCopyWith<$Res> {
|
||||
factory $IncrementCopyWith(Increment value, $Res Function(Increment) then) =
|
||||
_$IncrementCopyWithImpl<$Res>;
|
||||
$Res call({int by});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$IncrementCopyWithImpl<$Res> implements $IncrementCopyWith<$Res> {
|
||||
_$IncrementCopyWithImpl(this._value, this._then);
|
||||
|
||||
final Increment _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function(Increment) _then;
|
||||
|
||||
@override
|
||||
$Res call({
|
||||
Object? by = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
by: by == freezed
|
||||
? _value.by
|
||||
: by // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$_IncrementCopyWith<$Res> implements $IncrementCopyWith<$Res> {
|
||||
factory _$$_IncrementCopyWith(
|
||||
_$_Increment value, $Res Function(_$_Increment) then) =
|
||||
__$$_IncrementCopyWithImpl<$Res>;
|
||||
@override
|
||||
$Res call({int by});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$_IncrementCopyWithImpl<$Res> extends _$IncrementCopyWithImpl<$Res>
|
||||
implements _$$_IncrementCopyWith<$Res> {
|
||||
__$$_IncrementCopyWithImpl(
|
||||
_$_Increment _value, $Res Function(_$_Increment) _then)
|
||||
: super(_value, (v) => _then(v as _$_Increment));
|
||||
|
||||
@override
|
||||
_$_Increment get _value => super._value as _$_Increment;
|
||||
|
||||
@override
|
||||
$Res call({
|
||||
Object? by = freezed,
|
||||
}) {
|
||||
return _then(_$_Increment(
|
||||
by: by == freezed
|
||||
? _value.by
|
||||
: by // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$_Increment implements _Increment {
|
||||
const _$_Increment({required this.by});
|
||||
|
||||
factory _$_Increment.fromJson(Map<String, dynamic> json) =>
|
||||
_$$_IncrementFromJson(json);
|
||||
|
||||
@override
|
||||
final int by;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Increment(by: $by)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$_Increment &&
|
||||
const DeepCollectionEquality().equals(other.by, by));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, const DeepCollectionEquality().hash(by));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
_$$_IncrementCopyWith<_$_Increment> get copyWith =>
|
||||
__$$_IncrementCopyWithImpl<_$_Increment>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$_IncrementToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Increment implements Increment {
|
||||
const factory _Increment({required final int by}) = _$_Increment;
|
||||
|
||||
factory _Increment.fromJson(Map<String, dynamic> json) =
|
||||
_$_Increment.fromJson;
|
||||
|
||||
@override
|
||||
int get by;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$_IncrementCopyWith<_$_Increment> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
Count _$CountFromJson(Map<String, dynamic> json) {
|
||||
return _Count.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$Count {
|
||||
int get value => throw _privateConstructorUsedError;
|
||||
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
@JsonKey(ignore: true)
|
||||
$CountCopyWith<Count> get copyWith => throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CountCopyWith<$Res> {
|
||||
factory $CountCopyWith(Count value, $Res Function(Count) then) =
|
||||
_$CountCopyWithImpl<$Res>;
|
||||
$Res call({int value});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CountCopyWithImpl<$Res> implements $CountCopyWith<$Res> {
|
||||
_$CountCopyWithImpl(this._value, this._then);
|
||||
|
||||
final Count _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function(Count) _then;
|
||||
|
||||
@override
|
||||
$Res call({
|
||||
Object? value = freezed,
|
||||
}) {
|
||||
return _then(_value.copyWith(
|
||||
value: value == freezed
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$_CountCopyWith<$Res> implements $CountCopyWith<$Res> {
|
||||
factory _$$_CountCopyWith(_$_Count value, $Res Function(_$_Count) then) =
|
||||
__$$_CountCopyWithImpl<$Res>;
|
||||
@override
|
||||
$Res call({int value});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$_CountCopyWithImpl<$Res> extends _$CountCopyWithImpl<$Res>
|
||||
implements _$$_CountCopyWith<$Res> {
|
||||
__$$_CountCopyWithImpl(_$_Count _value, $Res Function(_$_Count) _then)
|
||||
: super(_value, (v) => _then(v as _$_Count));
|
||||
|
||||
@override
|
||||
_$_Count get _value => super._value as _$_Count;
|
||||
|
||||
@override
|
||||
$Res call({
|
||||
Object? value = freezed,
|
||||
}) {
|
||||
return _then(_$_Count(
|
||||
value == freezed
|
||||
? _value.value
|
||||
: value // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$_Count implements _Count {
|
||||
const _$_Count(this.value);
|
||||
|
||||
factory _$_Count.fromJson(Map<String, dynamic> json) =>
|
||||
_$$_CountFromJson(json);
|
||||
|
||||
@override
|
||||
final int value;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Count(value: $value)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$_Count &&
|
||||
const DeepCollectionEquality().equals(other.value, value));
|
||||
}
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
int get hashCode =>
|
||||
Object.hash(runtimeType, const DeepCollectionEquality().hash(value));
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@override
|
||||
_$$_CountCopyWith<_$_Count> get copyWith =>
|
||||
__$$_CountCopyWithImpl<_$_Count>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$_CountToJson(
|
||||
this,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _Count implements Count {
|
||||
const factory _Count(final int value) = _$_Count;
|
||||
|
||||
factory _Count.fromJson(Map<String, dynamic> json) = _$_Count.fromJson;
|
||||
|
||||
@override
|
||||
int get value;
|
||||
@override
|
||||
@JsonKey(ignore: true)
|
||||
_$$_CountCopyWith<_$_Count> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
24
code_sharing/shared/lib/src/models.g.dart
Normal file
24
code_sharing/shared/lib/src/models.g.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'models.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$_Increment _$$_IncrementFromJson(Map<String, dynamic> json) => _$_Increment(
|
||||
by: json['by'] as int,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$_IncrementToJson(_$_Increment instance) =>
|
||||
<String, dynamic>{
|
||||
'by': instance.by,
|
||||
};
|
||||
|
||||
_$_Count _$$_CountFromJson(Map<String, dynamic> json) => _$_Count(
|
||||
json['value'] as int,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$_CountToJson(_$_Count instance) => <String, dynamic>{
|
||||
'value': instance.value,
|
||||
};
|
||||
Reference in New Issue
Block a user