Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mahmoudelsayed7/sqflite
SqlDb - SQLite Database Handler for Flutter.
https://github.com/mahmoudelsayed7/sqflite
database db flutter flutter-apps flutter-package flutter-plugin flutter-sqflite local-database localstorage pub-dev sqflite sqflite-database sql sqlite3
Last synced: about 1 month ago
JSON representation
SqlDb - SQLite Database Handler for Flutter.
- Host: GitHub
- URL: https://github.com/mahmoudelsayed7/sqflite
- Owner: MAHMOUDELSAYED7
- Created: 2024-08-19T00:19:41.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-08-20T02:04:31.000Z (6 months ago)
- Last Synced: 2024-12-06T06:30:27.155Z (2 months ago)
- Topics: database, db, flutter, flutter-apps, flutter-package, flutter-plugin, flutter-sqflite, local-database, localstorage, pub-dev, sqflite, sqflite-database, sql, sqlite3
- Language: Dart
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# SqlDb - SQLite Database Handler for Flutter
This Flutter project provides a reusable, singleton class, `SqlDb`, to handle SQLite database operations using the `sqflite` package. The class manages the creation, initialization, and CRUD operations on a database, allowing developers to define their own table schemas dynamically.
## Features
- **Singleton Design Pattern**: Ensures only one instance of the database is used throughout the app.
- **Database Initialization**: Automatically initializes the database and creates tables based on user-defined schemas.
- **Flexible Table Management**: Add custom table definitions that will be used to create tables when the database is initialized.
- **CRUD Operations**: Includes methods for creating, reading, updating, and deleting records.
- **User Management**: Allows inserting and retrieving users, with support for username and password validation.
- **Invoice Management**: Supports saving invoices and generating the next invoice number for a user.
## 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
sqflite: ^2.0.0+4
path: ^1.8.3
```
### Installation
Clone the repository or copy the SqlDb class into your Flutter project.Initialize the database in your main application file. You can do this using an anonymous object:
```dart
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
await SqlDb().initializeDatabase();
runApp(MyApp());
}
```
## NoticeYou can easily customize the database structure by modifying the table definitions in the `_onCreate` method. This makes `SqlDb` suitable for various applications, from simple apps to complex systems with unique data needs.
## Contact
For any questions or feedback, please reach out via email: [[email protected]]([email protected])