import 'package:hive/hive.dart'; import '../models/transaction.dart' as app; import '../models/budget.dart'; class HiveService { static const String transactionsBox = 'transactions'; static const String budgetsBox = 'budgets'; static Future init() async { await Hive.openBox(transactionsBox); await Hive.openBox(budgetsBox); } // --- Métodos para Transações --- Future insertTransaction(app.Transaction transaction) async { final box = Hive.box(transactionsBox); int key = await box.add(transaction); return key; } Future> getTransactions() async { final box = Hive.box(transactionsBox); return box.values.toList(); } Future updateTransaction(int key, app.Transaction transaction) async { final box = Hive.box(transactionsBox); await box.put(key, transaction); } Future deleteTransaction(int key) async { final box = Hive.box(transactionsBox); await box.delete(key); } // --- Métodos para Orçamentos --- Future insertBudget(Budget budget) async { final box = Hive.box(budgetsBox); int key = await box.add(budget); return key; } Future> getBudgets() async { final box = Hive.box(budgetsBox); return box.values.toList(); } Future updateBudget(int key, Budget budget) async { final box = Hive.box(budgetsBox); await box.put(key, budget); } Future deleteBudget(int key) async { final box = Hive.box(budgetsBox); await box.delete(key); } }