2023-02-06 19:42:24 +00:00
|
|
|
class TransactionDirection {
|
|
|
|
const TransactionDirection({required this.raw, required this.title, this.iconPath});
|
2021-12-24 12:52:08 +00:00
|
|
|
|
2023-02-06 19:42:24 +00:00
|
|
|
final int raw;
|
|
|
|
final String title;
|
|
|
|
final String? iconPath;
|
|
|
|
|
|
|
|
static const incoming =
|
|
|
|
TransactionDirection(raw: 0, title: 'incoming', iconPath: 'assets/images/down_arrow.png');
|
|
|
|
static const outgoing =
|
|
|
|
TransactionDirection(raw: 1, title: 'outgoing', iconPath: 'assets/images/up_arrow.png');
|
|
|
|
|
|
|
|
static TransactionDirection parseFromInt(int raw) {
|
|
|
|
switch (raw) {
|
|
|
|
case 0:
|
|
|
|
return TransactionDirection.incoming;
|
|
|
|
case 1:
|
|
|
|
return TransactionDirection.outgoing;
|
|
|
|
default:
|
|
|
|
throw Exception(
|
|
|
|
'Unexpected token: raw for TransactionDirection parseTransactionDirectionFromInt');
|
|
|
|
}
|
2021-12-24 12:52:08 +00:00
|
|
|
}
|
|
|
|
|
2023-02-06 19:42:24 +00:00
|
|
|
static TransactionDirection parseFromString(String raw) {
|
|
|
|
switch (raw) {
|
|
|
|
case "0":
|
|
|
|
return TransactionDirection.incoming;
|
|
|
|
case "1":
|
|
|
|
return TransactionDirection.outgoing;
|
|
|
|
default:
|
|
|
|
throw Exception(
|
|
|
|
'Unexpected token: raw for TransactionDirection parseTransactionDirectionFromNumber');
|
|
|
|
}
|
2021-12-24 12:52:08 +00:00
|
|
|
}
|
2023-02-06 19:42:24 +00:00
|
|
|
}
|