DesignRowCheck class

Checks that the controls sharing a row line up as a person sees them: by their drawn outlines, not their boxes.

A control's box is not always what a person sees as its outline. A glass button whose outer ring barely stands off a light dialog reads 146 by 44 beside a filled one of 150 by 48: the same boxes, so DesignKeylineCheck passes them, and a row whose tops, bottoms and sides do not match. This check reads each control's outline from the drawn pixels, inside its face (the box DesignLabelCheck and DesignKeylineCheck read, so a shadow outside it never counts): the outermost rows and columns holding a pixel whose contrast with what is just around the face reaches contrastFloor, words and icons left out (its own, and any drawn over it from beside it: a navigation item's icon over its pressed-state layer). For a rectangular bevel, the check also compares its light and dark rim colours. This preserves the full outline when one rim is close to the background. A face no pixel of which reaches the floor (a fill a hue apart from its ground, a pane of glass) is read by its box, as is one a look marks with DesignKeylineFace. Controls of one kind touching side by side in one track drawn round them (a segmented control's segments, a joined strip's buttons: a fill or a stroke all round, no more than 8 px round them, holding nothing else; a table header's rule under its headings is no track) are read by the track's outline.

A row is the controls that one box lays out side by side: a dialog's actions, a split button's halves, a search field and its button, an app bar's icons, and each run of a wrap (chips over two lines). Across a row, held to tolerance device pixels as drawn, and each problem given as laid out and as drawn:

  • one top and one bottom, among the controls with a face of their own each more than half as high as the tallest (a checkbox beside a button is not one of them). The control most of them agree with (of two, the taller) is the one the others are held to, and one drawn smaller is named, whatever the reason: a button "Cancel" beside a button "OK": its top is level with theirs as laid out, 6 device px below as drawn.
  • every control's capitals (its label's, a text entry's typed text or hint) on the row's centre line, that control's middle: a button "OK" beside a button "Cancel": the capitals of "OK" are 1 px below the row's centre line as laid out, 3 device px below as drawn. Words over or under other words (a card's title over its body) or under a picture (an icon tile's name, a label under a painted glyph) are placed, not centred, and are not held to it.
  • a control with no face of its own has no outline to compare: an icon button drawn as a bare glyph, a text button, a navigation destination whose indicator holds only its icon, an icon whose badge is the only face in it, a tab whose face shows only the line under it, a text entry whose only paint round it draws nothing (an input decorator with no border). A face holds what its control shows (a text entry's line, else its label and every icon), and what is drawn of it holds its middle. Such a control is read by its label's capitals (its words beside its icon, or alone), else by its icon's middle, on the centre line: a button beside a button "OK": its icon is 1 px below the row's centre line as laid out, 2 device px below as drawn. In a row of only these, the centre line is the one most of them agree with.
  • equal sides, where the row is laid out with equal sides on its surface (the nearest face around it, else the screen), across it or centred on it: a row of a button "Cancel" and a button "OK": its sides are 24 px in as laid out, 26 px on the left and 24 px on the right as drawn.

A text field's own parts (its entry and the toggle, clear button or switch inside its face, read by what they show, not by touch targets that may overhang it) are one field, not a row; a control whose middle is outside the image (scrolled out of its strip), that a clip round it hides in part (a week scrolled in its strip, its weekend past the strip's edge), or that another surface covers, wholly or in part (a window in front of it, a later layer of a stack: what a pointer at its middle or an edge's reaches is painted after it, and fills), is not read. A row inside a region that says why its controls may differ in height or centre (DesignKeylineRegion.mixedHeights: a gallery's ladder of one control per size) is not held; a to-do there is named. To free one row only, put the region round that row.

Before the check, a test loads the look's fonts and lets the screen's images decode, as DesignLabelCheck shows. Only what is painted is read. A test pumps a screen (a gallery page, an app screen, a dialog) and checks it from its root, the app round the page, so its bars are read with it (a gallery's own bar, an app's top bar and navigation):

final report = await const DesignRowCheck(look: 'Comic').check(
  tester.element(find.byType(SettingsScreen)),
  runAsync: tester.runAsync,
);
report.verify();
Annotations

Constructors

DesignRowCheck({required String look, double contrastFloor = 1.25, double tolerance = 0.5, double pixelRatio = 3})
A check for look.
const

Properties

contrastFloor → double
The contrast with what is around a face (WCAG's ratio of relative luminances, 1 to 21) a drawn pixel needs to count as part of its outline: below it, a person sees the pixel as the ground.
final
hashCode → int
The hash code for this object.
no setterinherited
look → String
The look's name, for messages.
final
pixelRatio → double
The scale the screen is drawn at to read its pixels.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tolerance → double
How far, in device pixels at pixelRatio, the drawn tops, bottoms and sides of a row may differ.
final

Methods

check(BuildContext context, {Future<T?> runAsync<T>(Future<T> work())?}) → Future<DesignAlignmentReport>
Checks every row of controls under context (on screen, under a repaint boundary as every route is). A test passes its tester's runAsync (reading pixels takes real time); null reads them directly.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited