easy_flutter_orm 0.0.1
SDKflutter
Platformandroidioswindowslinuxmacosweb
An easy-to-use ORM for Flutter to manage SQLite databases.
Here's a template for your README.md file with usage instructions:
# easy_flutter_orm
A simple and easy-to-use ORM (Object-Relational Mapping) for Flutter to handle SQLite databases with ease.
## Features
- Create, read, update, and delete (CRUD) operations.
- Simple and intuitive API.
- Automatically map database tables to Dart objects.
## Installation
Add `easy_flutter_orm` as a dependency in your `pubspec.yaml` file:
```yaml
dependencies:
easy_flutter_orm: ^0.0.1
Then, run:
flutter pub get
Usage
1. Import the package:
import 'package:easy_flutter_orm/easy_flutter_orm.dart';
2. Define your model:
Create a Dart class that represents a table in your SQLite database. Annotate it with @Table() to specify the table name.
import 'package:easy_flutter_orm/easy_flutter_orm.dart';
@Table('users')
class User {
@PrimaryKey(autoGenerate: true)
final int? id;
@Column('name')
final String name;
@Column('email')
final String email;
User({this.id, required this.name, required this.email});
}
3. Initialize the ORM:
Before you can use the ORM, you need to initialize it with a database name.
Future<void> main() async {
await EasyFlutterORM.init('my_database.db');
runApp(MyApp());
}
4. Perform CRUD operations:
- Insert:
User newUser = User(name: 'John Doe', email: 'john.doe@example.com');
await EasyFlutterORM.insert<User>(newUser);
- Query:
List<User> users = await EasyFlutterORM.query<User>();
- Update:
User updatedUser = User(id: 1, name: 'Jane Doe', email: 'jane.doe@example.com');
await EasyFlutterORM.update<User>(updatedUser);
- Delete:
await EasyFlutterORM.delete<User>(1); // Delete user with ID 1
Contributing
Contributions are welcome! Please submit a pull request or open an issue.
License
This project is licensed under the MIT License - see the LICENSE file for details.
You can modify this template to better fit your plugin's specific features and usage patterns. Once you've updated the `README.md`, you'll be ready to package and upload your plugin to pub.dev!