testing library

Test helpers for grids.

A FitGrid paints its cells rather than building a Text widget for each one. That is the whole point of the package, and it has one consequence that will otherwise cost you an afternoon: find.text('Amit') will never match a row, because there is no Text widget to find. There is a TextPainter, and it is inside a RenderBox.

These helpers read the same cell specs the renderer paints from, so assertions see exactly what the user sees.

testWidgets('shows the employee', (tester) async {
  await tester.pumpWidget(app);
  expect(fitGridCellText(row: 0, column: 1), 'Amit');
});

Nothing here imports flutter_test. That is deliberate: testing.dart is shipped API, and a library that imported the test framework would drag it into the dependency graph of every application that uses the package. The helpers find the grid themselves rather than being handed a WidgetTester, and you use your own expect on what they return.

Classes

FitGridCellSpec
Everything the render layer needs to paint one text cell.
FitGridCellVisualSpec
A chart painted into a cell, already reduced to geometry: fractions of the cell's content box, so the render layer needs nothing but the box to draw it and the spec compares cheaply.
RenderFitGridSection
Paints a rectangular block of grid cells as text, with real widgets layered over the cells that need them.

Enums

FitGridVisualKind
Which painted chart a cell carries.

Functions

fitGridCellIsTruncated({required int row, required int column, int index = 0}) → bool
Whether a cell's text is currently ellipsized.
fitGridCellSpec({required int row, required int column, int index = 0}) → FitGridCellSpec
The full paint spec behind a cell — its style, icon, highlights and accessibility label as well as its text.
fitGridCellText({required int row, required int column, int index = 0}) → String
The text painted into one cell.
fitGridColumnIds({int index = 0}) → List<String>
The ids of the visible columns, in the order they are laid out — pinned columns first, whatever order they were declared in.
fitGridColumnLeft(String columnId, {int index = 0}) → double
The on-screen x of a column's leading edge, in the section's coordinates.
fitGridColumnWidth(String columnId, {int index = 0}) → double
The resolved width of a column, by column id.
fitGridLaidOutRowCount({int index = 0}) → int
Number of rows currently laid out.
fitGridPaintedCellCount({int index = 0}) → int
How many cell painters the grid is holding.
fitGridPaintedTextHeight({required int row, required int column, int index = 0}) → double?
The height of a cell's laid-out text.
fitGridRowCount({int index = 0}) → int
Number of rows the grid holds, including those outside the viewport.
fitGridRowHeight(int row, {int index = 0}) → double
The resolved height of a row.
fitGridRowOffset(int row, {int index = 0}) → double
The top edge of a row in content space, measured from the first row.
fitGridRowText(int row, {int index = 0}) → List<String>
The text painted across one row.
fitGridSection({int index = 0}) → RenderFitGridSection
The painted section behind a grid.
fitGridSections() → List<RenderFitGridSection>
Every painted grid section currently mounted, in tree order.
fitGridSemanticsNodeCount({int index = 0}) → int
How many accessibility nodes the grid is holding.