33 lines
1,004 B
Dart
33 lines
1,004 B
Dart
|
import 'package:currency_picker/currency_picker.dart';
|
||
|
import 'package:json_annotation/json_annotation.dart';
|
||
|
import 'package:prasule/api/category.dart';
|
||
|
import 'package:prasule/api/entry.dart';
|
||
|
part 'wallet.g.dart';
|
||
|
|
||
|
Currency _currencyFromJson(Map<String, dynamic> data) =>
|
||
|
Currency.from(json: data);
|
||
|
|
||
|
@JsonSerializable()
|
||
|
class Wallet {
|
||
|
final String name;
|
||
|
final List<WalletCategory> categories;
|
||
|
final List<WalletEntry> entries;
|
||
|
double availableAmount;
|
||
|
@JsonKey(fromJson: _currencyFromJson)
|
||
|
final Currency currency;
|
||
|
|
||
|
Wallet(
|
||
|
{required this.name,
|
||
|
required this.currency,
|
||
|
this.categories = const [],
|
||
|
this.entries = const [],
|
||
|
this.availableAmount = 0});
|
||
|
|
||
|
/// Connect the generated [_$WalletEntry] function to the `fromJson`
|
||
|
/// factory.
|
||
|
factory Wallet.fromJson(Map<String, dynamic> json) => _$WalletFromJson(json);
|
||
|
|
||
|
/// Connect the generated [_$PersonToJson] function to the `toJson` method.
|
||
|
Map<String, dynamic> toJson() => _$WalletToJson(this);
|
||
|
}
|