Доходы, ребалансировка, налоги, импорт, цели, здоровье данных, правила, транзакции, категории, cashflow, pending: новые виджеты и токены темы, dart format. Тесты подстроены под новые модели.
29 lines
977 B
Dart
29 lines
977 B
Dart
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../core/api/api_client.dart';
|
|
import '../../core/cache/cached.dart';
|
|
import 'data/goals_api.dart';
|
|
|
|
final goalsApiProvider = Provider<GoalsApi>(
|
|
(ref) => GoalsApi(ref.watch(apiProvider).dio),
|
|
);
|
|
|
|
/// See `docs/ai/offline-cache.md`.
|
|
final goalsProvider = FutureProvider.autoDispose<Cached<List<Goal>>>(
|
|
(ref) => ref.watch(goalsApiProvider).list(),
|
|
);
|
|
|
|
/// Progress is computed server-side and refetched per goal — the client never projects
|
|
/// anything itself.
|
|
final goalProgressProvider = FutureProvider.autoDispose
|
|
.family<Cached<GoalProgress>, int>((ref, id) async {
|
|
return ref.watch(goalsApiProvider).progress(id);
|
|
});
|
|
|
|
/// After any create/patch/delete the list and every progress card are refetched: the
|
|
/// numbers are recomputed on the server, not patched in the app.
|
|
void invalidateGoals(WidgetRef ref) {
|
|
ref.invalidate(goalsProvider);
|
|
ref.invalidate(goalProgressProvider);
|
|
}
|