Riverpod + go_router с auth-guard, NavigationRail на широком экране и bottom bar на узком. Токены в flutter_secure_storage, на web access живёт в памяти. Интерцептор подставляет токен и делает ровно один refresh на 401. Деньги приходят строками и форматируются через Decimal: парсить их в double значило бы терять копейки ровно там, где бэкенд их бережёт.
17 lines
702 B
Dart
17 lines
702 B
Dart
import 'package:fintracker_api/fintracker_api.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
import '../../core/api/api_client.dart';
|
|
|
|
/// Every account, archived included — screens decide what to show.
|
|
final accountsProvider = FutureProvider.autoDispose<List<AccountOut>>((ref) async {
|
|
final r = await ref.watch(apiProvider).getAccountsApi().accountsList();
|
|
return r.data ?? const [];
|
|
});
|
|
|
|
/// `account_id -> name`, for screens that only carry the id (transactions, rules).
|
|
final accountNamesProvider = Provider.autoDispose<Map<int, String>>((ref) {
|
|
final accounts = ref.watch(accountsProvider).valueOrNull ?? const [];
|
|
return {for (final a in accounts) a.id: a.name};
|
|
});
|