TableProperty class

Represents a database table column/property for code generation.

This class models a PostgreSQL table column and provides utilities for mapping database types to Dart types, handling nullability, and generating appropriate Dart field declarations.

Type Mapping

The following PostgreSQL types are supported:

  • Numeric: int4, int8, serial, bigserialint
  • Floating: float4, float8, double precisiondouble
  • Text: text, varchar, uuid, timestampString
  • Boolean: boolean, boolbool
  • JSON: json, jsonbMap<String, dynamic>
  • Arrays: _textList<String>, _numericList<num>

Example

For a PostgreSQL column:

email VARCHAR(255) NULL

A TableProperty would be:

TableProperty(
  name: 'email',
  type: 'character varying',
  isNullable: true,
  isPrimaryKey: false,
  isAutoIncrement: false,
)

Which generates the Dart field:

final String? email;

Constructors

TableProperty.new({required String name, required String type, required bool isNullable, required bool isPrimaryKey, required bool isAutoIncrement})
Creates a new TableProperty instance.

Properties

dartName String
The property name in Dart camelCase convention.
no setter
dartType String
The corresponding Dart type for this database column.
no setter
field String
Generates the Dart field declaration code.
no setter
hashCode int
The hash code for this object.
no setterinherited
isAutoIncrement bool
Whether this column auto-increments (e.g., SERIAL, AUTO_INCREMENT).
final
isNullable bool
Whether the column allows NULL values.
final
isPrimaryKey bool
Whether this column is part of the primary key.
final
name String
The original database column name (e.g., 'created_at').
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
The PostgreSQL data type of the column (e.g., 'varchar', 'int4').
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited