field property

String get field

Generates the Dart field declaration code.

Creates a properly formatted Dart field declaration with:

  • final modifier for immutability
  • Correct type with nullability marker (?) if needed
  • Property name in camelCase

Examples:

  • final int id; (non-nullable)
  • final String? email; (nullable)
  • final Map<String, dynamic>? metadata; (nullable JSON)

Returns the complete field declaration as a string.

Implementation

String get field {
  return "final $dartType${isNullable ? "?" : ""} $dartName;";
}