Package greatly inspired by JsonCodable
(from Dart), makes it easy to create
a JSON format of a template for Supabase.
Before | After |
---|---|
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
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
:
flutter_supabase_macro:
git:
url: https://github.com/ThomasDevApps/flutter_supabase_macro.git
Let's imagine the User
class :
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 :
@FlutterSupabaseMacro(primaryKey: 'id') // Add this (primaryKey is 'id' by default)
class User {
// ...
}
It will generate a toJsonSupabase()
method that returns a Map<String, dynamic>
.
This package is still undergoing experimentation, and is in no way intended for use in production apps.
Not officially affiliated with Supabase.