supabase_easy 0.0.3
supabase_easy: ^0.0.3 copied to clipboard
A powerful and lightweight Supabase wrapper for Flutter that reduces boilerplate for Auth, Database CRUD, and Real-time listeners by 60-70%.
Supabase Easy 🚀 #
Reduce Supabase + Flutter boilerplate by 60–70% while keeping type safety, flexibility, and performance.
Features #
- Simplified Initialization: Initialize Supabase with a single call.
- EasyAuth: Simplified authentication API for common tasks.
- EasyRepository: Generic repository for type-safe CRUD operations.
- EasyStorage: Simplified file management for buckets.
- Simplified Real-time: Easy-to-use streams for real-time updates.
Note: This plugin is designed to be highly useful for rapid development. We are committed to continuously optimizing the codebase and keeping it updated with the latest Supabase and Flutter features.
Screenshots #
| Login & Signup | Task Management |
|---|---|
| [Login] | [TodoList] |
| [Signup] | [Add Task] |
| [Empty State] |
Getting Started #
Add supabase_easy to your pubspec.yaml:
dependencies:
supabase_easy: ^0.0.3
Setup Supabase #
To use this plugin, you need to:
- Create a Supabase project at supabase.com.
- Create your tables (e.g.,
todos). - Enable Row Level Security (RLS) on your tables.
- Add policies to allow authenticated or public access. For testing, you can use:
CREATE POLICY "Allow public access" ON todos FOR ALL TO public USING (true) WITH CHECK (true); - Get your Project URL and Anon Key from the Supabase Dashboard (Settings > API).
Important: OAuth & Storage Setup #
To ensure OAuth and Storage work correctly, please verify the following in your Supabase Dashboard:
🔐 OAuth Configuration
- Enable Providers: Go to
Auth > Providersand enable your desired providers (e.g., Google, GitHub). - Redirect URLs: Add your application's deep link URL (e.g.,
io.supabase.flutter://callback) toAuth > URL Configuration > Redirect URLs. - Platform Setup: Follow the Supabase Auth guide for specific platform configurations (Android/iOS deep linking).
📁 Storage Configuration
- Create Buckets: Go to
Storage > Bucketsand create the buckets you reference in your code (e.g.,profiles,avatars). - Set RLS Policies: By default, buckets are private. You must add policies to allow users to upload or view files.
- For public viewing:
Allow SELECT for everyone. - For user uploads:
Allow INSERT/UPDATE for authenticated users.
- For public viewing:
- Public/Private: Decide if your bucket should be "Public" (files accessible via public URL) or "Private" (files require a signed URL).
Usage #
1. Initialize #
await SupabaseEasy.initialize(
url: 'https://your-project.supabase.co',
anonKey: 'your-anon-key',
);
2. Define your Model #
class Todo extends EasyModel {
@override
final String id;
final String title;
Todo({required this.id, required this.title});
@override
Map<String, dynamic> toJson() => {'id': id, 'title': title};
factory Todo.fromJson(Map<String, dynamic> json) => Todo(
id: json['id'],
title: json['title'],
);
}
3. Use Repository #
final todoRepo = EasyRepository<Todo>(
tableName: 'todos',
fromJson: Todo.fromJson,
);
// Get all
final todos = await todoRepo.getAll();
// Create
await todoRepo.create(Todo(id: '1', title: 'Buy milk'));
// Real-time stream
todoRepo.stream(primaryKey: ['id']).listen((todos) {
print(todos);
});
4. Simplified Auth #
await EasyAuth.signIn(email: '...', password: '...');
print(EasyAuth.currentUser?.email);
5. Storage #
// Upload file
await EasyStorage.upload(
bucketId: 'avatars',
path: 'user_1.png',
file: File('path/to/image.png'),
);
// Get public URL
final url = EasyStorage.getPublicUrl(
bucketId: 'avatars',
path: 'user_1.png',
);
Example #
Check out the example folder for a complete Todo app implementation using this plugin.
License #
This project is licensed under the MIT License - see the LICENSE file for details.