Skip to content

Macro greatly inspired by JsonCodable (from Dart), makes it easy to create a JSON format of a template for Supabase.

License

Notifications You must be signed in to change notification settings

ThomasDevApps/flutter_supabase_macro

Repository files navigation

Flutter Supabase Macro

testing workflow

Package greatly inspired by JsonCodable (from Dart), makes it easy to create a JSON format of a template for Supabase.

Before After
before after

❔ 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 :

flutter_supabase_macro:
  git:
    url: https://github.com/ThomasDevApps/flutter_supabase_macro.git

🔎 How it works

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>.

📖 Additional information

This package is still undergoing experimentation, and is in no way intended for use in production apps.

Not officially affiliated with Supabase.

About

Macro greatly inspired by JsonCodable (from Dart), makes it easy to create a JSON format of a template for Supabase.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages