Files
flisp_app/lib/service/flisp_service.dart
2025-11-09 23:52:36 +08:00

40 lines
737 B
Dart

import 'package:flisp_app/models/flisp.dart';
import 'package:hive_flutter/hive_flutter.dart';
class FlispService {
static const String boxName = 'flisps';
Box<Flisp> get box => Hive.box<Flisp>(boxName);
Future<bool> addFlisp(Flisp flisp) async {
try {
await box.add(flisp);
return true;
} catch (e) {
return false;
}
}
List<Flisp> getAllFlisps() {
return box.values.toList();
}
Future<bool> updateFlisp(Flisp flisp) async {
try {
await flisp.save();
return true;
} catch (e) {
return false;
}
}
Future<bool> deleteFlisp(Flisp flisp) async {
try {
await flisp.delete();
return true;
} catch (e) {
return false;
}
}
}