easy_db 1.0.0
easy_db: ^1.0.0 copied to clipboard
The simplest database plugin for Flutter. Just 4 methods and you're done! Perfect for beginners and anyone who hates complex database setup.
Easy_DB #
The simplest database plugin for Flutter. Just 4 methods and you're done!
π― Why Easy_DB? #
- Only 4 methods to learn:
init,insert,find,delete - Zero setup: No table creation, no schema definitions
- Beginner friendly: Designed for people who hate complexity
- Works everywhere: Android, iOS, Web, Desktop (coming soon)
π Super Quick Start #
import 'package:easy_db/easy_db.dart';
// Just 4 lines to store and retrieve data!
await EasyDb.init('app.db');
await EasyDb.insert('users', {'name': 'John', 'age': 30});
List<Map<String, dynamic>> users = await EasyDb.find('users');
await EasyDb.close();
π¦ Installation #
Add this to your package's pubspec.yaml file:
dependencies:
easy_db: ^1.0.0
Then run:
flutter pub get
π οΈ Simple Usage #
Store Data #
// Initialize once in your app
await EasyDb.init('my_app.db');
// Store anything - no table setup needed!
await EasyDb.insert('users', {
'name': 'John Doe',
'email': 'john@example.com',
'age': 30,
});
Retrieve Data #
// Get all records
List<Map<String, dynamic>> allUsers = await EasyDb.find('users');
// Get specific records
List<Map<String, dynamic>> adults = await EasyDb.find(
'users',
where: 'age >= ?',
whereArgs: [18],
);
Delete Data #
// Delete specific records
await EasyDb.delete('users', where: 'age < ?', whereArgs: [18]);
π² Advanced Features (Still Simple!) #
Update Records #
await EasyDb.update(
'users',
{'age': 31},
where: 'name = ?',
whereArgs: ['John Doe']
);
Raw SQL (When You Need It) #
// Complex queries
List<Map<String, dynamic>> results = await EasyDb.rawQuery(
'SELECT * FROM users WHERE age > ? ORDER BY name',
[25]
);
// Custom updates
await EasyDb.rawUpdate(
'UPDATE users SET age = age + 1 WHERE active = ?',
[1]
);
Convenience Methods #
// Get first matching record
Map<String, dynamic>? user = await EasyDb.findOne(
'users',
where: 'email = ?',
whereArgs: ['john@example.com']
);
// Check if records exist
bool hasAdults = await EasyDb.exists('users', where: 'age >= ?', whereArgs: [18]);
// Count records
int userCount = await EasyDb.count('users');
π API Summary #
| Method | What it does | Example |
|---|---|---|
EasyDb.init(dbName) |
Start using Easy_DB | await EasyDb.init('app.db') |
EasyDb.insert(table, data) |
Save data | await EasyDb.insert('users', {'name': 'John'}) |
EasyDb.find(table, {...}) |
Get data | await EasyDb.find('users') |
EasyDb.update(table, data, {...}) |
Change data | await EasyDb.update('users', {'age': 31}, ...) |
EasyDb.delete(table, {...}) |
Remove data | await EasyDb.delete('users', ...) |
EasyDb.close() |
Clean up | await EasyDb.close() |
π― Perfect For #
- Beginners who want to store app data without learning SQL
- Prototypes that need quick data persistence
- Small apps with simple data storage needs
- Anyone who hates complex database setup
π± Example App #
import 'package:flutter/material.dart';
import 'package:easy_db/easy_db.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
List<Map<String, dynamic>> users = [];
@override
void initState() {
super.initState();
_loadUsers();
}
_loadUsers() async {
await EasyDb.init('app.db');
setState(() {
users = await EasyDb.find('users');
});
}
_addUser() async {
await EasyDb.insert('users', {
'name': 'John',
'email': 'john@example.com',
});
_loadUsers(); // Refresh the list
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Users: ${users.length}')),
body: ListView.builder(
itemCount: users.length,
itemBuilder: (context, index) {
final user = users[index];
return ListTile(
title: Text(user['name']),
subtitle: Text(user['email']),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: _addUser,
child: const Icon(Icons.add),
),
),
);
}
}
π Getting Started #
- Add
easy_dbto yourpubspec.yaml - Run
flutter pub get - Import and use:
import 'package:easy_db/easy_db.dart'; - Start storing data in 2 lines!
π Platform Support #
| Platform | Status |
|---|---|
| Android | β Ready |
| iOS | β Coming soon |
| Web | β Coming soon |
| Desktop | β Coming soon |
π€ Contributing #
Want to help? Great!
- Fork the repo
- Make it even simpler
- Send a pull request
π License #
MIT - Do whatever you want with it!
π¨βπ» Author #
itsaqibdev - Making Flutter development easier for everyone
- Website: itsaqibdev.me
- GitHub: @itsaqibdev
- Fiverr: itsaqibdev