Compare commits

..

No commits in common. "147178e4ddefdbcbe3c1131db70a65ce1f12168c" and "fa852faadc2ff33f472c7f05a1655fa32b511e75" have entirely different histories.

2 changed files with 14 additions and 10 deletions

View File

@ -48,15 +48,15 @@ class _ProjectionPageState extends State<ProjectionPage> {
// Summaries for display as well as calculation of totals for projections. // Summaries for display as well as calculation of totals for projections.
Widget expenseSummary = SummaryCardForTotals( Widget expenseSummary = SummaryCardForTotals(
list: DatabaseHelper.instance.getExpenses(), list: DatabaseHelper.instance.getExpenses(),
itemType: ItemType.expense, summaryTypeLabel: ItemType.expense.title,
); );
Widget incomeSummary = SummaryCardForTotals( Widget incomeSummary = SummaryCardForTotals(
list: DatabaseHelper.instance.getIncomes(), list: DatabaseHelper.instance.getIncomes(),
itemType: ItemType.income, summaryTypeLabel: ItemType.income.title,
); );
Widget assetSummary = SummaryCardForTotals( Widget assetSummary = SummaryCardForTotals(
list: DatabaseHelper.instance.getAssets(), list: DatabaseHelper.instance.getAssets(),
itemType: ItemType.asset, summaryTypeLabel: ItemType.asset.title,
); );
// Calculations for the projections. // Calculations for the projections.
@ -155,16 +155,14 @@ class SummaryCardForTotals extends StatelessWidget {
const SummaryCardForTotals({ const SummaryCardForTotals({
super.key, super.key,
required this.list, required this.list,
required this.itemType, required this.summaryTypeLabel,
}); });
final Future<List<TrackedItem>> list; final Future<List<TrackedItem>> list;
final ItemType itemType; final String summaryTypeLabel;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
String summaryTypeLabel = itemType.title.toString();
return FutureBuilder<List<TrackedItem>>( return FutureBuilder<List<TrackedItem>>(
future: list, future: list,
builder: ( builder: (
@ -177,9 +175,12 @@ class SummaryCardForTotals extends StatelessWidget {
// Calculate the total fields based on item type. // Calculate the total fields based on item type.
double dailyTotal = 0, monthlyTotal = 0, yearlyTotal = 0; double dailyTotal = 0, monthlyTotal = 0, yearlyTotal = 0;
ItemType? itemType;
for (TrackedItem e in snapshot.data!) { for (TrackedItem e in snapshot.data!) {
if (e.type != itemType) { if (itemType == null) {
throw "List in SummaryCardForTotals has incorrect item types, abort!"; itemType = e.type!;
} else if (itemType != e.type) {
throw "List in SummaryCardForTotals has multiple item types, abort!";
} }
if (e.type == ItemType.asset) { if (e.type == ItemType.asset) {
@ -193,6 +194,9 @@ class SummaryCardForTotals extends StatelessWidget {
/* Load page variables based on calculated totals. */ /* Load page variables based on calculated totals. */
switch (itemType) { switch (itemType) {
case null:
break;
case ItemType.asset: case ItemType.asset:
_assetTotal = monthlyTotal; _assetTotal = monthlyTotal;
break; break;

View File

@ -1,7 +1,7 @@
name: expense_tracker name: expense_tracker
description: Track recurring expenses against income and liquid assets. description: Track recurring expenses against income and liquid assets.
publish_to: 'none' publish_to: 'none'
version: 0.1.3 version: 0.1.2
environment: environment:
sdk: ^3.6.1 sdk: ^3.6.1