Add ItemType for determining which DB methods should be called based on the screen data. Begin implementing it.

This commit is contained in:
2025-02-21 09:30:46 -07:00
parent be66f52cbf
commit 42548d437c
7 changed files with 92 additions and 50 deletions

View File

@ -1,4 +1,6 @@
// Local
import 'package:flutter_expense_tracker/models/item_type.dart';
import '/models/tracked_item.dart';
import '/models/frequency.dart';
@ -7,6 +9,7 @@ class Expense extends TrackedItem {
Expense({
super.id,
super.type = ItemType.expense,
required super.name,
required super.amount,
required super.frequency,

22
lib/models/item_type.dart Normal file
View File

@ -0,0 +1,22 @@
enum ItemType {
expense(
title: "Expense",
plural: "Expenses",
),
income(
title: "Income",
plural: "Incomes",
),
asset(
title: "Asset",
plural: "Assets",
);
const ItemType({
required this.title,
required this.plural,
});
final String title;
final String plural;
}

View File

@ -1,8 +1,11 @@
// 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;
@ -10,6 +13,7 @@ abstract class TrackedItem {
TrackedItem({
this.id,
this.type,
required this.name,
required this.amount,
this.frequency,