supabase_gen 1.6.1 copy "supabase_gen: ^1.6.1" to clipboard
supabase_gen: ^1.6.1 copied to clipboard

Generate Flutter repositories & models from Supabase database. Requires supabase_flutter ^2.8.4.

Supabase Gen #

A Dart package that generates Flutter repositories and models from your Supabase database schema.

Features #

  • Automatically generates Dart model classes from your database tables
  • Creates repository classes with methods for CRUD operations
  • Maintains relationships between tables
  • Type-safe code generation with smart handling of PostgreSQL types
  • Comprehensive numeric type conversion for all PostgreSQL numeric formats
  • Handles array types, JSON types, and binary data properly
  • Easy to configure and use

New in Version 1.2.0 #

  • Fixed the int/double type mismatch issue: Safely handles PostgreSQL numeric/decimal/real types without runtime errors
  • Improved type handling: Added comprehensive support for all PostgreSQL data types
  • Smart type conversion: Automatically converts between similar types (int/double/string) safely
  • Enhanced array handling: Better support for array types with appropriate casting

UUID Primary Key Handling #

This package now properly handles UUID primary keys in PostgreSQL tables. When a primary key field is of type UUID:

  1. The field is generated as nullable (String?) in the model class
  2. The field is optional in the constructor (not marked as required)
  3. The field is only included in the toJson() method if it's not null

This allows for proper handling of auto-generated UUID fields in PostgreSQL, preventing the "invalid input syntax for type uuid" error when inserting new records.

Using the UUID Class #

For better type safety, the package also provides a UUID class that can be used instead of raw strings:

import 'package:supabase_gen/supabase_gen.dart';

// Creating a UUID from a string
final id = UUID('123e4567-e89b-12d3-a456-426614174000');

// The UUID class validates the format
try {
  final invalidId = UUID('not-a-uuid');
} catch (e) {
  print('Invalid UUID format'); // This will be printed
}

// Using with your models
final myModel = MyModel(
  id: UUID('123e4567-e89b-12d3-a456-426614174000'),
  // other fields...
);

// For new records, omit the UUID field
final newModel = MyModel(
  // id is omitted, will be generated by PostgreSQL
  // other fields...
);

Note: To use the UUID class with your models, you'll need to manually update your model classes to use the UUID type instead of String.

Installation #

Add the package to your pubspec.yaml:

dev_dependencies:
  supabase_gen: ^1.2.0
1
likes
50
points
65
downloads

Publisher

unverified uploader

Weekly Downloads

Generate Flutter repositories & models from Supabase database. Requires supabase_flutter ^2.8.4.

Repository (GitHub)

License

MIT (license)

Dependencies

args, logging, path, postgres, recase, supabase_flutter, yaml

More

Packages that depend on supabase_gen