Move EnvironmentModel

This commit is contained in:
Ashita Prasad
2025-02-24 12:12:52 +05:30
parent b69a7d5e06
commit 38c6d8ecf6
3 changed files with 2 additions and 2 deletions

View File

@@ -0,0 +1,82 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import '../consts.dart';
part 'environment_model.freezed.dart';
part 'environment_model.g.dart';
@freezed
class EnvironmentModel with _$EnvironmentModel {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory EnvironmentModel({
required String id,
@Default("") String name,
@Default([]) List<EnvironmentVariableModel> values,
}) = _EnvironmentModel;
factory EnvironmentModel.fromJson(Map<String, Object?> json) =>
_$EnvironmentModelFromJson(json);
}
@freezed
class EnvironmentVariableModel with _$EnvironmentVariableModel {
@JsonSerializable(
explicitToJson: true,
anyMap: true,
)
const factory EnvironmentVariableModel({
required String key,
required String value,
@Default(EnvironmentVariableType.variable) EnvironmentVariableType type,
@Default(false) bool enabled,
}) = _EnvironmentVariableModel;
factory EnvironmentVariableModel.fromJson(Map<String, Object?> json) =>
_$EnvironmentVariableModelFromJson(json);
}
const kEnvironmentVariableEmptyModel =
EnvironmentVariableModel(key: "", value: "");
const kEnvironmentSecretEmptyModel = EnvironmentVariableModel(
key: "", value: "", type: EnvironmentVariableType.secret);
class EnvironmentVariableSuggestion {
final String environmentId;
final EnvironmentVariableModel variable;
final bool isUnknown;
const EnvironmentVariableSuggestion({
required this.environmentId,
required this.variable,
this.isUnknown = false,
});
EnvironmentVariableSuggestion copyWith({
String? environmentId,
EnvironmentVariableModel? variable,
bool? isUnknown,
}) {
return EnvironmentVariableSuggestion(
environmentId: environmentId ?? this.environmentId,
variable: variable ?? this.variable,
isUnknown: isUnknown ?? this.isUnknown,
);
}
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;
return other is EnvironmentVariableSuggestion &&
other.environmentId == environmentId &&
other.variable == variable &&
other.isUnknown == isUnknown;
}
@override
int get hashCode =>
environmentId.hashCode ^ variable.hashCode ^ isUnknown.hashCode;
}

View File

@@ -0,0 +1,430 @@
// 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, unnecessary_question_mark
part of 'environment_model.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#adding-getters-and-methods-to-our-models');
EnvironmentModel _$EnvironmentModelFromJson(Map<String, dynamic> json) {
return _EnvironmentModel.fromJson(json);
}
/// @nodoc
mixin _$EnvironmentModel {
String get id => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
List<EnvironmentVariableModel> get values =>
throw _privateConstructorUsedError;
/// Serializes this EnvironmentModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of EnvironmentModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$EnvironmentModelCopyWith<EnvironmentModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $EnvironmentModelCopyWith<$Res> {
factory $EnvironmentModelCopyWith(
EnvironmentModel value, $Res Function(EnvironmentModel) then) =
_$EnvironmentModelCopyWithImpl<$Res, EnvironmentModel>;
@useResult
$Res call({String id, String name, List<EnvironmentVariableModel> values});
}
/// @nodoc
class _$EnvironmentModelCopyWithImpl<$Res, $Val extends EnvironmentModel>
implements $EnvironmentModelCopyWith<$Res> {
_$EnvironmentModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of EnvironmentModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? values = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
values: null == values
? _value.values
: values // ignore: cast_nullable_to_non_nullable
as List<EnvironmentVariableModel>,
) as $Val);
}
}
/// @nodoc
abstract class _$$EnvironmentModelImplCopyWith<$Res>
implements $EnvironmentModelCopyWith<$Res> {
factory _$$EnvironmentModelImplCopyWith(_$EnvironmentModelImpl value,
$Res Function(_$EnvironmentModelImpl) then) =
__$$EnvironmentModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String id, String name, List<EnvironmentVariableModel> values});
}
/// @nodoc
class __$$EnvironmentModelImplCopyWithImpl<$Res>
extends _$EnvironmentModelCopyWithImpl<$Res, _$EnvironmentModelImpl>
implements _$$EnvironmentModelImplCopyWith<$Res> {
__$$EnvironmentModelImplCopyWithImpl(_$EnvironmentModelImpl _value,
$Res Function(_$EnvironmentModelImpl) _then)
: super(_value, _then);
/// Create a copy of EnvironmentModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? name = null,
Object? values = null,
}) {
return _then(_$EnvironmentModelImpl(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as String,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
values: null == values
? _value._values
: values // ignore: cast_nullable_to_non_nullable
as List<EnvironmentVariableModel>,
));
}
}
/// @nodoc
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$EnvironmentModelImpl implements _EnvironmentModel {
const _$EnvironmentModelImpl(
{required this.id,
this.name = "",
final List<EnvironmentVariableModel> values = const []})
: _values = values;
factory _$EnvironmentModelImpl.fromJson(Map<String, dynamic> json) =>
_$$EnvironmentModelImplFromJson(json);
@override
final String id;
@override
@JsonKey()
final String name;
final List<EnvironmentVariableModel> _values;
@override
@JsonKey()
List<EnvironmentVariableModel> get values {
if (_values is EqualUnmodifiableListView) return _values;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_values);
}
@override
String toString() {
return 'EnvironmentModel(id: $id, name: $name, values: $values)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$EnvironmentModelImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.name, name) || other.name == name) &&
const DeepCollectionEquality().equals(other._values, _values));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(
runtimeType, id, name, const DeepCollectionEquality().hash(_values));
/// Create a copy of EnvironmentModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$EnvironmentModelImplCopyWith<_$EnvironmentModelImpl> get copyWith =>
__$$EnvironmentModelImplCopyWithImpl<_$EnvironmentModelImpl>(
this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$EnvironmentModelImplToJson(
this,
);
}
}
abstract class _EnvironmentModel implements EnvironmentModel {
const factory _EnvironmentModel(
{required final String id,
final String name,
final List<EnvironmentVariableModel> values}) = _$EnvironmentModelImpl;
factory _EnvironmentModel.fromJson(Map<String, dynamic> json) =
_$EnvironmentModelImpl.fromJson;
@override
String get id;
@override
String get name;
@override
List<EnvironmentVariableModel> get values;
/// Create a copy of EnvironmentModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$EnvironmentModelImplCopyWith<_$EnvironmentModelImpl> get copyWith =>
throw _privateConstructorUsedError;
}
EnvironmentVariableModel _$EnvironmentVariableModelFromJson(
Map<String, dynamic> json) {
return _EnvironmentVariableModel.fromJson(json);
}
/// @nodoc
mixin _$EnvironmentVariableModel {
String get key => throw _privateConstructorUsedError;
String get value => throw _privateConstructorUsedError;
EnvironmentVariableType get type => throw _privateConstructorUsedError;
bool get enabled => throw _privateConstructorUsedError;
/// Serializes this EnvironmentVariableModel to a JSON map.
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
/// Create a copy of EnvironmentVariableModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
$EnvironmentVariableModelCopyWith<EnvironmentVariableModel> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $EnvironmentVariableModelCopyWith<$Res> {
factory $EnvironmentVariableModelCopyWith(EnvironmentVariableModel value,
$Res Function(EnvironmentVariableModel) then) =
_$EnvironmentVariableModelCopyWithImpl<$Res, EnvironmentVariableModel>;
@useResult
$Res call(
{String key, String value, EnvironmentVariableType type, bool enabled});
}
/// @nodoc
class _$EnvironmentVariableModelCopyWithImpl<$Res,
$Val extends EnvironmentVariableModel>
implements $EnvironmentVariableModelCopyWith<$Res> {
_$EnvironmentVariableModelCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
/// Create a copy of EnvironmentVariableModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? key = null,
Object? value = null,
Object? type = null,
Object? enabled = null,
}) {
return _then(_value.copyWith(
key: null == key
? _value.key
: key // ignore: cast_nullable_to_non_nullable
as String,
value: null == value
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as EnvironmentVariableType,
enabled: null == enabled
? _value.enabled
: enabled // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$EnvironmentVariableModelImplCopyWith<$Res>
implements $EnvironmentVariableModelCopyWith<$Res> {
factory _$$EnvironmentVariableModelImplCopyWith(
_$EnvironmentVariableModelImpl value,
$Res Function(_$EnvironmentVariableModelImpl) then) =
__$$EnvironmentVariableModelImplCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{String key, String value, EnvironmentVariableType type, bool enabled});
}
/// @nodoc
class __$$EnvironmentVariableModelImplCopyWithImpl<$Res>
extends _$EnvironmentVariableModelCopyWithImpl<$Res,
_$EnvironmentVariableModelImpl>
implements _$$EnvironmentVariableModelImplCopyWith<$Res> {
__$$EnvironmentVariableModelImplCopyWithImpl(
_$EnvironmentVariableModelImpl _value,
$Res Function(_$EnvironmentVariableModelImpl) _then)
: super(_value, _then);
/// Create a copy of EnvironmentVariableModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline')
@override
$Res call({
Object? key = null,
Object? value = null,
Object? type = null,
Object? enabled = null,
}) {
return _then(_$EnvironmentVariableModelImpl(
key: null == key
? _value.key
: key // ignore: cast_nullable_to_non_nullable
as String,
value: null == value
? _value.value
: value // ignore: cast_nullable_to_non_nullable
as String,
type: null == type
? _value.type
: type // ignore: cast_nullable_to_non_nullable
as EnvironmentVariableType,
enabled: null == enabled
? _value.enabled
: enabled // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
@JsonSerializable(explicitToJson: true, anyMap: true)
class _$EnvironmentVariableModelImpl implements _EnvironmentVariableModel {
const _$EnvironmentVariableModelImpl(
{required this.key,
required this.value,
this.type = EnvironmentVariableType.variable,
this.enabled = false});
factory _$EnvironmentVariableModelImpl.fromJson(Map<String, dynamic> json) =>
_$$EnvironmentVariableModelImplFromJson(json);
@override
final String key;
@override
final String value;
@override
@JsonKey()
final EnvironmentVariableType type;
@override
@JsonKey()
final bool enabled;
@override
String toString() {
return 'EnvironmentVariableModel(key: $key, value: $value, type: $type, enabled: $enabled)';
}
@override
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$EnvironmentVariableModelImpl &&
(identical(other.key, key) || other.key == key) &&
(identical(other.value, value) || other.value == value) &&
(identical(other.type, type) || other.type == type) &&
(identical(other.enabled, enabled) || other.enabled == enabled));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType, key, value, type, enabled);
/// Create a copy of EnvironmentVariableModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@override
@pragma('vm:prefer-inline')
_$$EnvironmentVariableModelImplCopyWith<_$EnvironmentVariableModelImpl>
get copyWith => __$$EnvironmentVariableModelImplCopyWithImpl<
_$EnvironmentVariableModelImpl>(this, _$identity);
@override
Map<String, dynamic> toJson() {
return _$$EnvironmentVariableModelImplToJson(
this,
);
}
}
abstract class _EnvironmentVariableModel implements EnvironmentVariableModel {
const factory _EnvironmentVariableModel(
{required final String key,
required final String value,
final EnvironmentVariableType type,
final bool enabled}) = _$EnvironmentVariableModelImpl;
factory _EnvironmentVariableModel.fromJson(Map<String, dynamic> json) =
_$EnvironmentVariableModelImpl.fromJson;
@override
String get key;
@override
String get value;
@override
EnvironmentVariableType get type;
@override
bool get enabled;
/// Create a copy of EnvironmentVariableModel
/// with the given fields replaced by the non-null parameter values.
@override
@JsonKey(includeFromJson: false, includeToJson: false)
_$$EnvironmentVariableModelImplCopyWith<_$EnvironmentVariableModelImpl>
get copyWith => throw _privateConstructorUsedError;
}

View File

@@ -0,0 +1,51 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'environment_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$EnvironmentModelImpl _$$EnvironmentModelImplFromJson(Map json) =>
_$EnvironmentModelImpl(
id: json['id'] as String,
name: json['name'] as String? ?? "",
values: (json['values'] as List<dynamic>?)
?.map((e) => EnvironmentVariableModel.fromJson(
Map<String, Object?>.from(e as Map)))
.toList() ??
const [],
);
Map<String, dynamic> _$$EnvironmentModelImplToJson(
_$EnvironmentModelImpl instance) =>
<String, dynamic>{
'id': instance.id,
'name': instance.name,
'values': instance.values.map((e) => e.toJson()).toList(),
};
_$EnvironmentVariableModelImpl _$$EnvironmentVariableModelImplFromJson(
Map json) =>
_$EnvironmentVariableModelImpl(
key: json['key'] as String,
value: json['value'] as String,
type:
$enumDecodeNullable(_$EnvironmentVariableTypeEnumMap, json['type']) ??
EnvironmentVariableType.variable,
enabled: json['enabled'] as bool? ?? false,
);
Map<String, dynamic> _$$EnvironmentVariableModelImplToJson(
_$EnvironmentVariableModelImpl instance) =>
<String, dynamic>{
'key': instance.key,
'value': instance.value,
'type': _$EnvironmentVariableTypeEnumMap[instance.type]!,
'enabled': instance.enabled,
};
const _$EnvironmentVariableTypeEnumMap = {
EnvironmentVariableType.variable: 'variable',
EnvironmentVariableType.secret: 'secret',
};