Skip to content

Commit

Permalink
Fixing refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
K-w-e committed Feb 20, 2024
1 parent 521f7e0 commit f85931e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions lib/pages/planning_page/manage_budget_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ class _ManageBudgetPageState extends ConsumerState<ManageBudgetPage> {
}

void updateBudget(Budget updatedBudget, int index) {
budgets[index] = updatedBudget;
setState(() {
deletedBudgets.add(budgets[index]);
budgets[index] = updatedBudget;
});
}

void deleteBudget(Budget removedBudget, int index) {
Expand Down Expand Up @@ -138,12 +141,12 @@ class _ManageBudgetPageState extends ConsumerState<ManageBudgetPage> {
child: SizedBox(
width: double.infinity,
child: ElevatedButton(
onPressed: () {
onPressed: () async {
for (var item in deletedBudgets) {
BudgetMethods().deleteByCategory(item.idCategory);
await BudgetMethods().deleteByCategory(item.idCategory);
}
for (var item in budgets) {
BudgetMethods().insertOrUpdate(item);
await BudgetMethods().insertOrUpdate(item);
}
setState(() {
widget.onRefreshBudgets();
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/planning_page/planning_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ class _PlanningPageState extends State<PlanningPage> {
child: Row(children: [
Text("MANAGE",
style: Theme.of(context).textTheme.labelLarge),
SizedBox(width: 5),
Icon(Icons.edit, size: 13)
const SizedBox(width: 5),
const Icon(Icons.edit, size: 13)
]))
],
),
Expand Down

0 comments on commit f85931e

Please sign in to comment.