Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahmoudelsayed69/hive
HiveDb - Hive Database Handler for Flutter
https://github.com/mahmoudelsayed69/hive
build-runner database db flutter flutter-apps hive hive-data-collection hive-database hive-db hive-flutter hive-generator hivedb local-database localdb localstorage pub-dev pub-package
Last synced: about 1 month ago
JSON representation
HiveDb - Hive Database Handler for Flutter
- Host: GitHub
- URL: https://github.com/mahmoudelsayed69/hive
- Owner: MAHMOUDELSAYED69
- Created: 2024-08-20T21:19:06.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-08-29T04:53:48.000Z (3 months ago)
- Last Synced: 2024-09-27T14:40:56.956Z (about 2 months ago)
- Topics: build-runner, database, db, flutter, flutter-apps, hive, hive-data-collection, hive-database, hive-db, hive-flutter, hive-generator, hivedb, local-database, localdb, localstorage, pub-dev, pub-package
- Language: Dart
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HiveDb - Hive Database Handler for Flutter
This Flutter project provides a reusable, singleton class, **HiveDb**, to handle Hive database operations. The class manages the initialization, configuration, and CRUD operations on a database, allowing developers to define their own data models and manage user accounts, pizzas, and invoices dynamically.
## Features
- **Singleton Pattern**: Uses a single database instance throughout the app.
- **Initialization**: Sets up the database and opens necessary boxes.
- **Table Management**: Allows custom table definitions for box creation.
- **CRUD Operations**: Provides methods for creating, reading, updating, and deleting records.
- **User Management**: Supports user insertion and retrieval with validation.
- **Invoice Management**: Saves invoices and generates the next invoice number.## Getting Started
### Prerequisites
Ensure you have Flutter installed and set up on your machine. You will also need to include the following dependencies in your `pubspec.yaml` file:
```yaml
dependencies:
flutter:
sdk: flutter
hive: ^2.0.0
hive_flutter: ^1.1.0
path_provider: ^2.0.10dev_dependencies:
build_runner: ^2.4.11
hive_generator: ^2.0.1
```
### Installation
1. Clone the repository or copy the HiveDb class into your Flutter project.2. Run the build_runner command in your terminal:
```
dart run build_runner build
```
3. Initialize the database in your main application file. You can do this using an anonymous object:```dart
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await HiveDb().initializeDatabase();
runApp(MyApp());
}
```
## NoticeYou can easily customize the database structure by modifying the user, pizza, and invoice classes as needed. This makes `HiveDb` suitable for a variety of applications, from simple projects to more complex systems with unique data requirements.
## ContactFor any questions or feedback, please reach out via email: [[email protected]]([email protected])