// Local import 'package:flutter_expense_tracker/models/item_type.dart'; import '/models/frequency.dart'; abstract class TrackedItem { int? id; ItemType? type; String name; double amount; Frequency? frequency; String description; TrackedItem({ this.id, this.type, required this.name, required this.amount, this.frequency, required this.description, }); static String amountText = "Amount"; String getAmountText() => amountText; @override String toString() { return toMap().toString(); } double calcComparableAmountYearly() { return frequency == null ? 0 : amount * frequency!.timesPerYear; } double calcComparableAmountDaily() { return frequency == null ? 0 : amount / frequency!.numDays; } Map toMap() { return frequency == null ? { 'id': id, 'name': name, 'amount': amount, 'description': description, } : { 'id': id, 'name': name, 'amount': amount, 'frequency': frequency!.title, 'description': description, }; } }