cake_wallet/cw_core/lib/transaction_direction.dart

37 lines
1.1 KiB
Dart
Raw Normal View History

2023-02-06 19:42:24 +00:00
class TransactionDirection {
const TransactionDirection({required this.raw, required this.title, this.iconPath});
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');
}
}
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');
}
}
2023-02-06 19:42:24 +00:00
}