LazyTable class
A virtual scrolling table widget. Only requests and renders rows within the viewport.
Column Widths and Layout Alignment
- Column alignments are mapped directly to columnWidths where cells are truncated or padded to match specified character spans.
Row Selection and Scrolling
- Selected row index is tracked via selectedRowIndex.
- adjustScroll dynamically recalculates scrollOffset to keep the active selection visible in the viewport.
- Since only visible rows are processed via itemBuilder, this widget scales efficiently to thousands of rows without memory overhead.
Example Usage
LazyTable(
headers: const ['ID', 'Logs'],
columnWidths: const [5, 40],
itemCount: 10000,
itemBuilder: (index) => ['#$index', 'Log message at $index'],
selectedRowIndex: activeRow,
);
Properties and Settings
| Property | Type | Description |
|---|---|---|
headers |
List<String> | Column title strings. |
columnWidths |
List<int> | Monospaced width boundaries for each column. |
itemCount |
int | Total size of the data source list. |
itemBuilder |
List<String> Function(int) |
Dynamic row builder callback. |
selectedRowIndex |
int | Active highlighted row index. |
Constructors
-
LazyTable({required List<
String> headers, required List<int> columnWidths, required int itemCount, required List<String> itemBuilder(int index), int scrollOffset = 0, int selectedRowIndex = 0, Style headerStyle = const Style(modifiers: Modifier.bold), Style rowStyle = Style.empty, Style selectedRowStyle = const Style(modifiers: Modifier.reverse), Style borderStyle = const Style(modifiers: Modifier.dim)}) - Creates a LazyTable.
Properties
- borderStyle → Style
-
Style applied to table borders.
final
-
columnWidths
→ List<
int> -
Monospaced width boundaries for each column.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ List<
String> -
Column title strings.
final
- headerStyle → Style
-
Style applied to the header row.
final
-
itemBuilder
→ List<
String> Function(int index) -
Dynamic row builder callback.
final
- itemCount → int
-
Total size of the data source list.
final
- key → Key?
-
The optional key for this widget.
finalinherited
- rowStyle → Style
-
Default style applied to unselected rows.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollOffset ↔ int
-
Current scroll offset for the top visible row.
getter/setter pair
- selectedRowIndex ↔ int
-
Active highlighted row index.
getter/setter pair
- selectedRowStyle → Style
-
Style applied to the selected row.
final
Methods
-
adjustScroll(
int viewportHeight) → void - Adjusts the scroll offset to keep selected row visible.
-
createElement(
) → Element -
Creates an Element to manage this widget's location in the tree.
inherited
-
getIntrinsicHeight(
int width) → int -
Computes the intrinsic height of this widget under the given
widthconstraint.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Buffer buffer, Rect area) → void -
Renders the widget onto the provided
bufferwithin the specifiedarea.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited