EnumModel class
Represents a PostgreSQL enum type for code generation.
This class models a database enum and provides utilities for generating the corresponding Dart enum code. It handles name transformations and value mappings required for proper Dart enum generation.
Example
For a PostgreSQL enum like:
CREATE TYPE user_status AS ENUM ('active', 'inactive', 'pending');
An EnumModel would be created with:
final enumModel = EnumModel(
name: 'user_status',
values: ['active', 'inactive', 'pending'],
);
This generates Dart code like:
enum UserStatus {
active,
inactive,
pending;
String get name {
switch (this) {
case UserStatus.active: return 'active';
case UserStatus.inactive: return 'inactive';
case UserStatus.pending: return 'pending';
}
}
}
Constructors
-
EnumModel.new({required String name, required List<
String> values}) - Creates a new EnumModel instance.
Properties
- enumName → String
-
The generated Dart enum name in PascalCase.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
mappedData
→ Map<
String, String> -
Maps Dart enum property names to their corresponding database string values.
no setter
- name → String
-
The original database enum name (e.g., 'user_status').
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
values
→ List<
String> -
The list of enum values from the database.
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