https://github.com/thomasdevapps/flutter_supabase_macro
Macro greatly inspired by JsonCodable (from Dart), makes it easy to create a JSON format of a template for Supabase.
https://github.com/thomasdevapps/flutter_supabase_macro
flutter macro macros supabase
Last synced: about 2 months ago
JSON representation
Macro greatly inspired by JsonCodable (from Dart), makes it easy to create a JSON format of a template for Supabase.
- Host: GitHub
- URL: https://github.com/thomasdevapps/flutter_supabase_macro
- Owner: ThomasDevApps
- License: other
- Created: 2024-10-08T14:21:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-15T11:10:30.000Z (over 1 year ago)
- Last Synced: 2025-02-11T17:57:40.526Z (about 1 year ago)
- Topics: flutter, macro, macros, supabase
- Language: Dart
- Homepage:
- Size: 137 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Flutter Supabase Macro

Package greatly inspired by `JsonCodable` (from Dart), makes it easy to create
a JSON format of a template for Supabase.
| Before | After |
|----------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
|  |  |
- [What is a macro](#-what-is-a-macro)
- [Getting started](#-getting-started)
- [How it works](#-how-it-works)
- [Additional information](#-additional-information)
## ❔ What is a macro
A Dart macro is a user-definable piece of code that takes in other code as
parameters and operates on it in real-time to create, modify, or add declarations.
Find out more at https://dart.dev/language/macros
## 🚀 Getting started
Because the macros are still under development, you need to follow these
instructions to be able to test this package : https://dart.dev/language/macros#set-up-the-experiment
Then add in your `pubspec.yaml` :
```yaml
flutter_supabase_macro:
git:
url: https://github.com/ThomasDevApps/flutter_supabase_macro.git
```
## 🔎 How it works
Let's imagine the `User` class :
```dart
class User {
final String id;
final String name;
final int age;
const User({required this.id, required this.name, required this.age});
}
```
Let's assume that in your Supabase `users` table, the primary key is named `id`.
All you need to do is add the following :
```dart
@FlutterSupabaseMacro(primaryKey: 'id') // Add this (primaryKey is 'id' by default)
class User {
// ...
}
```
It will generate a `toJsonSupabase()` method that returns a `Map`.
## 📖 Additional information
This package is still undergoing experimentation, and is in no way intended for
use in production apps.
Not officially affiliated with Supabase.