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:

  1. Create a Supabase project at supabase.com.
  2. Create your tables (e.g., todos).
  3. Enable Row Level Security (RLS) on your tables.
  4. 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);
    
  5. 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

  1. Enable Providers: Go to Auth > Providers and enable your desired providers (e.g., Google, GitHub).
  2. Redirect URLs: Add your application's deep link URL (e.g., io.supabase.flutter://callback) to Auth > URL Configuration > Redirect URLs.
  3. Platform Setup: Follow the Supabase Auth guide for specific platform configurations (Android/iOS deep linking).

📁 Storage Configuration

  1. Create Buckets: Go to Storage > Buckets and create the buckets you reference in your code (e.g., profiles, avatars).
  2. 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.
  3. 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.