diff --git a/lib/pages/home/transactions.dart b/lib/pages/home/transactions.dart index 8753a3d1..37c58733 100644 --- a/lib/pages/home/transactions.dart +++ b/lib/pages/home/transactions.dart @@ -45,6 +45,7 @@ class _HomeTransactionsState extends State DateTime? _lastDate; List _rowsWithDate = []; + late TransStock stock; final TransactionFilters _filters = TransactionFilters(); @@ -104,15 +105,22 @@ class _HomeTransactionsState extends State ); }); } + + stock = context.read().transStock!; } @override void dispose() { + stock.removeListener(notifRefresh); _pagingController.dispose(); super.dispose(); } + void notifRefresh() { + _pagingController.refresh(); + } + Future _fetchPage(int pageKey) async { final TransStock? stock = context.read().transStock; diff --git a/lib/stock.dart b/lib/stock.dart index 2657219c..64741a41 100644 --- a/lib/stock.dart +++ b/lib/stock.dart @@ -2,13 +2,14 @@ import 'dart:async'; import 'dart:convert'; import 'package:chopper/chopper.dart' show Response; +import 'package:flutter/material.dart'; import 'package:stock/stock.dart'; import 'package:waterflyiii/generated/swagger_fireflyiii_api/firefly_iii.enums.swagger.dart' as enums show TransactionTypeFilter; import 'package:waterflyiii/generated/swagger_fireflyiii_api/firefly_iii.swagger.dart'; -class TransStock { +class TransStock with ChangeNotifier { final FireflyIii api; late Stock _singleStock; @@ -160,6 +161,7 @@ class TransStock { _getStock.clearAll(); _getAccountStock.clearAll(); _getSearchStock.clearAll(); + notifyListeners(); } Future setTransaction(TransactionRead transaction) async {