Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import 'dart:typed_data';
import 'package:equatable/equatable.dart';
import 'package:json_annotation/json_annotation.dart';
part 'payment_state.g.dart';
@JsonSerializable()
class PaymentState extends Equatable {
const PaymentState({
required this.publicKey,
required this.nick,
this.avatar,
required this.description,
required this.amount,
required this.isSent,
});
factory PaymentState.fromJson(Map<String, dynamic> json) =>
_$PaymentStateFromJson(json);
final String publicKey;
final String nick;
@JsonKey(fromJson: _fromList, toJson: _toList)
final Uint8List? avatar;
final String description;
final double amount;
final bool isSent;
Map<String, dynamic> toJson() => _$PaymentStateToJson(this);
PaymentState copyWith({
String? publicKey,
String? nick,
Uint8List? avatar,
String? description,
double? amount,
bool? isSent,
}) {
return PaymentState(
publicKey: publicKey ?? this.publicKey,
nick: nick ?? this.nick,
avatar: avatar ?? this.avatar,
description: description ?? this.description,
amount: amount ?? this.amount,
isSent: isSent ?? this.isSent,
);
}
static PaymentState emptyPayment = const PaymentState(
publicKey: '',
nick: '',
description: '',
amount: 0,
isSent: false,
);
@override
List<Object?> get props =>
<dynamic>[publicKey, nick, avatar, description, amount, isSent];
static Uint8List _fromList(List<int> list) => Uint8List.fromList(list);
static List<int> _toList(Uint8List? uint8List) =>
uint8List != null ? uint8List.toList() : <int>[];
}