TableCellHelper class
A helper class for TableCell, and is used to decide which TableCell to fill the whole TableRow in vertical direction, which is not implemented by flutter.
Example:
// in State class
final _helper = TableCellHelper(9, 2); // 9x2
// 1. in initState and didUpdateWidget method
// 2. or in build method
// 3. or use StatefulWidgetWithCallback with postFrameCallbackForXXX
WidgetsBinding.instance!.addPostFrameCallback((_) {
if (_helper.searchForHighestCells()) {
if (mounted) setState(() {});
}
});
// Table constructor in build method
Table(
children: [
for (int i = 0; i < 9; i++)
TableRow(
children: [
for (int j = 0; j < 2; j++)
TableCell(
key: _helper.getCellKey(i, j)
verticalAlignment: _helper.determineCellAlignment(i, j, TableCellVerticalAlignment.top),
child: Text('item ($i, $j)'),
),
],
),
],
)
// for update Table content
_helper.reset(newRow, newHeight);
if (mounted) setState(() {});
Constructors
- TableCellHelper(int _rows, int _columns)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
determineCellAlignment(
int i, int j, [TableCellVerticalAlignment? initialValue]) → TableCellVerticalAlignment? - Determines the TableCell's TableCellVerticalAlignment with given index.
-
getCellKey(
int i, int j) → GlobalKey< State< StatefulWidget> > - Returns the TableCell's GlobalKey for given index.
-
hasSearched(
) → bool - Returns true if searchForHighestCells has already been invoked to search.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
int rows, int columns) → void -
Resets the TableCellHelper with new rows and columns, which should be used
when TableRow count or TableCell content was changed, following
setState
. -
searchForHighestCells(
) → bool - Searches the highest TableCell in multiple TableRow and this function returns true if the highests list is regenerated.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited