TCsvEditor class
A rich, interactive CSV upload, header mapping, and inline-editable data table.
TCsvEditor provides an all-in-one solution for CSV management:
- File upload: Drag & drop or browse
.csv,.tsv,.txtfiles, or paste raw CSV text. - Header mapping: Automatically matches CSV headers to expected schema columns, with interactive visual re-mapping for mismatched column names.
- Inline editing: Type-aware table cells:
- Text: TTextField
- Number / Integer: TNumberField
- Boolean: TSwitch toggle via TTableHeader.toggle
- Validation: Real-time cell & row error detection (required fields, number parsing, custom rules).
- Actions: Add/delete/duplicate rows, download CSV starter template, export edited data to CSV, and execute upload/save callbacks.
Basic Usage
TCsvEditor(
title: 'Import Inventory',
columns: [
TCsvColumn.text(key: 'name', header: 'Product Name', isRequired: true),
TCsvColumn.number(key: 'price', header: 'Price (\$)', isRequired: true),
TCsvColumn.integer(key: 'stock', header: 'Stock Qty', defaultValue: 0),
TCsvColumn.boolean(key: 'active', header: 'Active / Available', defaultValue: true),
],
onSave: (data) async {
print('Uploaded rows: ${data.length}');
},
)
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- TCsvEditor
- Available extensions
Constructors
-
TCsvEditor({Key? key, required List<
TCsvColumn> columns, List<Map< ? initialData, Future<String, dynamic> >void> onSave(List<Map< data)?, ValueChanged<String, dynamic> >List< ? onDataChanged, String? title = 'CSV Data Editor', String? subtitle = 'Upload a CSV file or add rows manually to review and edit data.', String saveButtonText = 'Upload Data', IconData saveButtonIcon = Icons.cloud_upload_outlined, bool showDownloadTemplate = true, bool showExport = true, bool allowAddRow = true, bool allowDeleteRow = true, bool allowDuplicateRow = true, bool allowPaste = true, bool autoPromptMappingOnDiff = true, TCsvEditorTheme? theme, int itemsPerPage = 20})Map< >String, dynamic> > -
const
Properties
- allowAddRow → bool
-
Whether to allow adding new rows manually.
final
- allowDeleteRow → bool
-
Whether to allow deleting rows.
final
- allowDuplicateRow → bool
-
Whether to allow duplicating rows.
final
- allowPaste → bool
-
Whether to allow raw CSV pasting.
final
- autoPromptMappingOnDiff → bool
-
Whether to automatically prompt the header mapping dialog when uploaded CSV headers differ.
final
-
columns
→ List<
TCsvColumn> -
The schema of expected columns for the CSV data.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
initialData
→ List<
Map< ?String, dynamic> > -
Initial rows to populate the table (optional).
final
- itemsPerPage → int
-
Items per page for pagination (0 or null for all items in a scrollable view).
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onDataChanged
→ ValueChanged<
List< ?Map< >String, dynamic> > -
Callback fired whenever the data in the table changes.
final
-
onSave
→ Future<
void> Function(List<Map< data)?String, dynamic> > -
Callback fired when the user clicks the primary Save / Upload button.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- saveButtonIcon → IconData
-
Icon for the primary save/upload button.
final
- saveButtonText → String
-
Label for the primary save/upload button.
final
- showDownloadTemplate → bool
-
Whether to show the Download Template button.
final
- showExport → bool
-
Whether to show the Export CSV button.
final
- subtitle → String?
-
Subtitle or instruction text.
final
- theme → TCsvEditorTheme?
-
Theme configuration for the editor.
final
- title → String?
-
Title displayed in the editor card header.
final
Methods
-
box(
{double minW = 0.0, double minH = 0.0, double maxW = double.infinity, double maxH = double.infinity}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a ConstrainedBox to apply layout constraints. -
center(
{bool when = true}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Center widget. -
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< TCsvEditor> -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
expanded(
{int flex = 1}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in an Expanded widget. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
padding(
[double left = 0.0, double top = 0.0, double right = 0.0, double bottom = 0.0]) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Padding with flexible edge control. -
paddingSymmetric(
{double h = 0.0, double v = 0.0}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Padding with symmetric horizontal and vertical spacing. -
size(
{double? w, double? h}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a SizedBox to apply fixed width and/or height. -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
-
visible(
bool visible, {bool maintainState = false}) → Widget -
Available on Widget, provided by the WidgetX extension
Wraps this widget in a Visibility widget. -
when(
bool condition) → Widget -
Available on Widget, provided by the WidgetX extension
Returns this widget ifconditionis true, otherwise returns SizedBox.shrink(). Usage: Text('Hello').when(isVisible)
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited