forked from eatvio/eatvio_app
card adding and selecting default one
This commit is contained in:
23
lib/features/my_finance/models/card_model.dart
Normal file
23
lib/features/my_finance/models/card_model.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'card_model.freezed.dart';
|
||||
part 'card_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class CardModel with _$CardModel {
|
||||
|
||||
factory CardModel({
|
||||
required int id,
|
||||
@JsonKey(name: 'bank_pan') required String cardNumber,
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool) required bool isDefault,
|
||||
}) = _CardModel;
|
||||
|
||||
factory CardModel.fromJson(Map<String, dynamic> json) => _$CardModelFromJson(json);
|
||||
}
|
||||
|
||||
bool parseBool(json) {
|
||||
if (json == 1 || json == true) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
232
lib/features/my_finance/models/card_model.freezed.dart
Normal file
232
lib/features/my_finance/models/card_model.freezed.dart
Normal file
@@ -0,0 +1,232 @@
|
||||
// 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 'card_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',
|
||||
);
|
||||
|
||||
CardModel _$CardModelFromJson(Map<String, dynamic> json) {
|
||||
return _CardModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$CardModel {
|
||||
int get id => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'bank_pan')
|
||||
String get cardNumber => throw _privateConstructorUsedError;
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool)
|
||||
bool get isDefault => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this CardModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of CardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$CardModelCopyWith<CardModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $CardModelCopyWith<$Res> {
|
||||
factory $CardModelCopyWith(CardModel value, $Res Function(CardModel) then) =
|
||||
_$CardModelCopyWithImpl<$Res, CardModel>;
|
||||
@useResult
|
||||
$Res call({
|
||||
int id,
|
||||
@JsonKey(name: 'bank_pan') String cardNumber,
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool) bool isDefault,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$CardModelCopyWithImpl<$Res, $Val extends CardModel>
|
||||
implements $CardModelCopyWith<$Res> {
|
||||
_$CardModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of CardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? cardNumber = null,
|
||||
Object? isDefault = null,
|
||||
}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
id:
|
||||
null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
cardNumber:
|
||||
null == cardNumber
|
||||
? _value.cardNumber
|
||||
: cardNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isDefault:
|
||||
null == isDefault
|
||||
? _value.isDefault
|
||||
: isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$CardModelImplCopyWith<$Res>
|
||||
implements $CardModelCopyWith<$Res> {
|
||||
factory _$$CardModelImplCopyWith(
|
||||
_$CardModelImpl value,
|
||||
$Res Function(_$CardModelImpl) then,
|
||||
) = __$$CardModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({
|
||||
int id,
|
||||
@JsonKey(name: 'bank_pan') String cardNumber,
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool) bool isDefault,
|
||||
});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$CardModelImplCopyWithImpl<$Res>
|
||||
extends _$CardModelCopyWithImpl<$Res, _$CardModelImpl>
|
||||
implements _$$CardModelImplCopyWith<$Res> {
|
||||
__$$CardModelImplCopyWithImpl(
|
||||
_$CardModelImpl _value,
|
||||
$Res Function(_$CardModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of CardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({
|
||||
Object? id = null,
|
||||
Object? cardNumber = null,
|
||||
Object? isDefault = null,
|
||||
}) {
|
||||
return _then(
|
||||
_$CardModelImpl(
|
||||
id:
|
||||
null == id
|
||||
? _value.id
|
||||
: id // ignore: cast_nullable_to_non_nullable
|
||||
as int,
|
||||
cardNumber:
|
||||
null == cardNumber
|
||||
? _value.cardNumber
|
||||
: cardNumber // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
isDefault:
|
||||
null == isDefault
|
||||
? _value.isDefault
|
||||
: isDefault // ignore: cast_nullable_to_non_nullable
|
||||
as bool,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$CardModelImpl implements _CardModel {
|
||||
_$CardModelImpl({
|
||||
required this.id,
|
||||
@JsonKey(name: 'bank_pan') required this.cardNumber,
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool) required this.isDefault,
|
||||
});
|
||||
|
||||
factory _$CardModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$CardModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final int id;
|
||||
@override
|
||||
@JsonKey(name: 'bank_pan')
|
||||
final String cardNumber;
|
||||
@override
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool)
|
||||
final bool isDefault;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'CardModel(id: $id, cardNumber: $cardNumber, isDefault: $isDefault)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$CardModelImpl &&
|
||||
(identical(other.id, id) || other.id == id) &&
|
||||
(identical(other.cardNumber, cardNumber) ||
|
||||
other.cardNumber == cardNumber) &&
|
||||
(identical(other.isDefault, isDefault) ||
|
||||
other.isDefault == isDefault));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, id, cardNumber, isDefault);
|
||||
|
||||
/// Create a copy of CardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$CardModelImplCopyWith<_$CardModelImpl> get copyWith =>
|
||||
__$$CardModelImplCopyWithImpl<_$CardModelImpl>(this, _$identity);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$CardModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _CardModel implements CardModel {
|
||||
factory _CardModel({
|
||||
required final int id,
|
||||
@JsonKey(name: 'bank_pan') required final String cardNumber,
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool)
|
||||
required final bool isDefault,
|
||||
}) = _$CardModelImpl;
|
||||
|
||||
factory _CardModel.fromJson(Map<String, dynamic> json) =
|
||||
_$CardModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
int get id;
|
||||
@override
|
||||
@JsonKey(name: 'bank_pan')
|
||||
String get cardNumber;
|
||||
@override
|
||||
@JsonKey(name: 'is_default', fromJson: parseBool)
|
||||
bool get isDefault;
|
||||
|
||||
/// Create a copy of CardModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$CardModelImplCopyWith<_$CardModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
21
lib/features/my_finance/models/card_model.g.dart
Normal file
21
lib/features/my_finance/models/card_model.g.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'card_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$CardModelImpl _$$CardModelImplFromJson(Map<String, dynamic> json) =>
|
||||
_$CardModelImpl(
|
||||
id: (json['id'] as num).toInt(),
|
||||
cardNumber: json['bank_pan'] as String,
|
||||
isDefault: parseBool(json['is_default']),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$$CardModelImplToJson(_$CardModelImpl instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'bank_pan': instance.cardNumber,
|
||||
'is_default': instance.isDefault,
|
||||
};
|
||||
14
lib/features/my_finance/models/payment_url_model.dart
Normal file
14
lib/features/my_finance/models/payment_url_model.dart
Normal file
@@ -0,0 +1,14 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'payment_url_model.freezed.dart';
|
||||
part 'payment_url_model.g.dart';
|
||||
|
||||
@freezed
|
||||
class PaymentUrlModel with _$PaymentUrlModel {
|
||||
|
||||
factory PaymentUrlModel({
|
||||
required String paymentUrl,
|
||||
}) = _PaymentUrlModel;
|
||||
|
||||
factory PaymentUrlModel.fromJson(Map<String, dynamic> json) => _$PaymentUrlModelFromJson(json);
|
||||
}
|
||||
174
lib/features/my_finance/models/payment_url_model.freezed.dart
Normal file
174
lib/features/my_finance/models/payment_url_model.freezed.dart
Normal file
@@ -0,0 +1,174 @@
|
||||
// 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 'payment_url_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',
|
||||
);
|
||||
|
||||
PaymentUrlModel _$PaymentUrlModelFromJson(Map<String, dynamic> json) {
|
||||
return _PaymentUrlModel.fromJson(json);
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
mixin _$PaymentUrlModel {
|
||||
String get paymentUrl => throw _privateConstructorUsedError;
|
||||
|
||||
/// Serializes this PaymentUrlModel to a JSON map.
|
||||
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||
|
||||
/// Create a copy of PaymentUrlModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
$PaymentUrlModelCopyWith<PaymentUrlModel> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class $PaymentUrlModelCopyWith<$Res> {
|
||||
factory $PaymentUrlModelCopyWith(
|
||||
PaymentUrlModel value,
|
||||
$Res Function(PaymentUrlModel) then,
|
||||
) = _$PaymentUrlModelCopyWithImpl<$Res, PaymentUrlModel>;
|
||||
@useResult
|
||||
$Res call({String paymentUrl});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class _$PaymentUrlModelCopyWithImpl<$Res, $Val extends PaymentUrlModel>
|
||||
implements $PaymentUrlModelCopyWith<$Res> {
|
||||
_$PaymentUrlModelCopyWithImpl(this._value, this._then);
|
||||
|
||||
// ignore: unused_field
|
||||
final $Val _value;
|
||||
// ignore: unused_field
|
||||
final $Res Function($Val) _then;
|
||||
|
||||
/// Create a copy of PaymentUrlModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? paymentUrl = null}) {
|
||||
return _then(
|
||||
_value.copyWith(
|
||||
paymentUrl:
|
||||
null == paymentUrl
|
||||
? _value.paymentUrl
|
||||
: paymentUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
)
|
||||
as $Val,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
abstract class _$$PaymentUrlModelImplCopyWith<$Res>
|
||||
implements $PaymentUrlModelCopyWith<$Res> {
|
||||
factory _$$PaymentUrlModelImplCopyWith(
|
||||
_$PaymentUrlModelImpl value,
|
||||
$Res Function(_$PaymentUrlModelImpl) then,
|
||||
) = __$$PaymentUrlModelImplCopyWithImpl<$Res>;
|
||||
@override
|
||||
@useResult
|
||||
$Res call({String paymentUrl});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
class __$$PaymentUrlModelImplCopyWithImpl<$Res>
|
||||
extends _$PaymentUrlModelCopyWithImpl<$Res, _$PaymentUrlModelImpl>
|
||||
implements _$$PaymentUrlModelImplCopyWith<$Res> {
|
||||
__$$PaymentUrlModelImplCopyWithImpl(
|
||||
_$PaymentUrlModelImpl _value,
|
||||
$Res Function(_$PaymentUrlModelImpl) _then,
|
||||
) : super(_value, _then);
|
||||
|
||||
/// Create a copy of PaymentUrlModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@pragma('vm:prefer-inline')
|
||||
@override
|
||||
$Res call({Object? paymentUrl = null}) {
|
||||
return _then(
|
||||
_$PaymentUrlModelImpl(
|
||||
paymentUrl:
|
||||
null == paymentUrl
|
||||
? _value.paymentUrl
|
||||
: paymentUrl // ignore: cast_nullable_to_non_nullable
|
||||
as String,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@JsonSerializable()
|
||||
class _$PaymentUrlModelImpl implements _PaymentUrlModel {
|
||||
_$PaymentUrlModelImpl({required this.paymentUrl});
|
||||
|
||||
factory _$PaymentUrlModelImpl.fromJson(Map<String, dynamic> json) =>
|
||||
_$$PaymentUrlModelImplFromJson(json);
|
||||
|
||||
@override
|
||||
final String paymentUrl;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'PaymentUrlModel(paymentUrl: $paymentUrl)';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
return identical(this, other) ||
|
||||
(other.runtimeType == runtimeType &&
|
||||
other is _$PaymentUrlModelImpl &&
|
||||
(identical(other.paymentUrl, paymentUrl) ||
|
||||
other.paymentUrl == paymentUrl));
|
||||
}
|
||||
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
int get hashCode => Object.hash(runtimeType, paymentUrl);
|
||||
|
||||
/// Create a copy of PaymentUrlModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
@override
|
||||
@pragma('vm:prefer-inline')
|
||||
_$$PaymentUrlModelImplCopyWith<_$PaymentUrlModelImpl> get copyWith =>
|
||||
__$$PaymentUrlModelImplCopyWithImpl<_$PaymentUrlModelImpl>(
|
||||
this,
|
||||
_$identity,
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, dynamic> toJson() {
|
||||
return _$$PaymentUrlModelImplToJson(this);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class _PaymentUrlModel implements PaymentUrlModel {
|
||||
factory _PaymentUrlModel({required final String paymentUrl}) =
|
||||
_$PaymentUrlModelImpl;
|
||||
|
||||
factory _PaymentUrlModel.fromJson(Map<String, dynamic> json) =
|
||||
_$PaymentUrlModelImpl.fromJson;
|
||||
|
||||
@override
|
||||
String get paymentUrl;
|
||||
|
||||
/// Create a copy of PaymentUrlModel
|
||||
/// with the given fields replaced by the non-null parameter values.
|
||||
@override
|
||||
@JsonKey(includeFromJson: false, includeToJson: false)
|
||||
_$$PaymentUrlModelImplCopyWith<_$PaymentUrlModelImpl> get copyWith =>
|
||||
throw _privateConstructorUsedError;
|
||||
}
|
||||
15
lib/features/my_finance/models/payment_url_model.g.dart
Normal file
15
lib/features/my_finance/models/payment_url_model.g.dart
Normal file
@@ -0,0 +1,15 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'payment_url_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_$PaymentUrlModelImpl _$$PaymentUrlModelImplFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _$PaymentUrlModelImpl(paymentUrl: json['paymentUrl'] as String);
|
||||
|
||||
Map<String, dynamic> _$$PaymentUrlModelImplToJson(
|
||||
_$PaymentUrlModelImpl instance,
|
||||
) => <String, dynamic>{'paymentUrl': instance.paymentUrl};
|
||||
Reference in New Issue
Block a user