TCsvColumn class
Defines a column schema for TCsvEditor.
TCsvColumn describes:
- key: Unique field key used in output maps.
- header: Expected header label.
- type: The column data type (TCsvColumnType.text, TCsvColumnType.number, TCsvColumnType.integer, TCsvColumnType.boolean).
- isRequired: Whether the value must be non-empty and valid.
- defaultValue: Fallback value when empty.
- aliases: Synonyms used to automatically match CSV headers if the uploaded CSV header names differ.
- validator: Custom validation rule.
Example
TCsvColumn.text(key: 'name', header: 'Product Name', isRequired: true)
TCsvColumn.number(key: 'price', header: 'Price (\$)')
TCsvColumn.boolean(key: 'in_stock', header: 'In Stock')
Constructors
-
TCsvColumn({required String key, required String header, TCsvColumnType type = TCsvColumnType.text, bool isRequired = false, dynamic defaultValue, List<
String> aliases = const [], String? validator(dynamic value)?, String format(dynamic value)?, String? placeholder, String? helperText, double minWidth = 140, double? maxWidth, int? flex, Alignment alignment = Alignment.centerLeft}) -
const
-
TCsvColumn.boolean({required String key, required String header, bool isRequired = false, dynamic defaultValue = false, List<
String> aliases = const [], String? validator(dynamic value)?, String format(dynamic value)?, String? placeholder, String? helperText, double minWidth = 110, double? maxWidth = 160, int? flex, Alignment alignment = Alignment.center}) -
Creates a boolean toggle / switch column.
const
-
TCsvColumn.integer({required String key, required String header, bool isRequired = false, dynamic defaultValue, List<
String> aliases = const [], String? validator(dynamic value)?, String format(dynamic value)?, String? placeholder, String? helperText, double minWidth = 140, double? maxWidth, int? flex, Alignment alignment = Alignment.centerRight}) -
Creates an integer number column.
const
-
TCsvColumn.number({required String key, required String header, bool isRequired = false, dynamic defaultValue, List<
String> aliases = const [], String? validator(dynamic value)?, String format(dynamic value)?, String? placeholder, String? helperText, double minWidth = 150, double? maxWidth, int? flex, Alignment alignment = Alignment.centerRight}) -
Creates a floating point / decimal number column.
const
-
TCsvColumn.text({required String key, required String header, bool isRequired = false, dynamic defaultValue, List<
String> aliases = const [], String? validator(dynamic value)?, String format(dynamic value)?, String? placeholder, String? helperText, double minWidth = 150, double? maxWidth, int? flex, Alignment alignment = Alignment.centerLeft}) -
Creates a text column.
const
Properties
-
aliases
→ List<
String> -
Alternative header names to check during auto-mapping (e.g.
['qty', 'quantity']).final - alignment → Alignment
-
Content alignment inside cell.
final
- defaultValue → dynamic
-
Default value if cell is empty or missing.
final
- flex → int?
-
Flex factor for column width.
final
- format → String Function(dynamic value)?
-
Custom formatter for display.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- header → String
-
Expected header title string.
final
- helperText → String?
-
Optional helper text.
final
- isRequired → bool
-
Whether this column requires a non-empty value.
final
- key → String
-
Field key in the resulting row map.
final
- maxWidth → double?
-
Maximum width of the column in the table.
final
- minWidth → double
-
Minimum width of the column in the table.
final
- placeholder → String?
-
Optional placeholder for inline editor.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → TCsvColumnType
-
Data type of the column.
final
- validator → String? Function(dynamic value)?
-
Custom validation function returning error message or null if valid.
final
Methods
-
formatValue(
dynamic value) → String - Formats value for display or CSV serialization.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parseValue(
dynamic rawValue) → dynamic - Parses a raw input value into the column's target data type.
-
toString(
) → String -
A string representation of this object.
inherited
-
validate(
dynamic value) → String? - Validates a parsed or raw value, returning an error message if invalid, or null if valid.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited