DesignCapCenter class
Draws a one-line label or text entry so that the middle of its capitals is the middle of its own box, as Baseline puts a baseline where it is told.
A text's box is its line: the font's ascent above the baseline and its descent below, and the engine puts the baseline on a whole pixel. So a label centred by its box sits a pixel or two off the middle, by a different amount in each typeface and size, and a face that centres its label looks as if it did not. This widget keeps its child's size and moves only what it paints: up or down, so that the capitals' middle, where the engine will draw it (its whole-pixel baseline paid in advance), is the box's middle. Whatever centres this box then centres the capitals: a Row's cross axis, Center, Align, a button's face, a tab, a title bar, a list row. Within half a device pixel, at any pixel ratio, text scale, fractional offset or scale, where the engine draws the font's outlines as they are (Core Text: iOS and macOS). An engine that hints them (FreeType: Linux, and the web's CanvasKit) also snaps the capitals' top to the pixel grid, up to a device pixel from the font's cap height, which moves their middle up to half of that further.
Wrap the label alone, never an icon: in a centred Row, an icon's box and this box share a middle, and the icon is drawn on it. A look wraps the label of each face once, in its own widgets; page code never writes it.
It reads the text entry under child when it holds one (a TextField's
editable line), else the first paragraph that is not an icon's glyph, with
its font size through its own text scaler. A label that wraps to more
than one line, or a child without a paragraph, is drawn where it is laid
out: the middle of two lines' capitals is no one line's.
Around a text entry, wrap its one-line TextField (its decoration
collapsed, as DesignTextEntryCheck asks), inside the look's own box: the
line is placed by the field's style, whether text is typed or its hint
shows, and the caret, the selection, the hint and taps move with it. A
row that holds a field and a button then holds their capitals on one
line, whatever their sizes.
The move is at most a few pixels, and what it paints may reach that far past the box; hit testing and semantics follow what is painted. So a clip drawn exactly round a text entry's 48 px reach trims its node by the move (a tap target test reads 47.7): a look leaves the clip room for the move (or clips nothing round the entry).
DesignCapCenter(capHeightFactor: 0.711, child: Text('Save'))
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- RenderObjectWidget
- SingleChildRenderObjectWidget
- DesignCapCenter
Constructors
- DesignCapCenter({Key? key, required double capHeightFactor, required Widget child})
-
Draws
child, a one-line label or text entry, with its capitals on its box's middle.const
Properties
- capHeightFactor → double
-
The height of the label's capitals as a fraction of its font size: the
typeface's cap height (its OS/2 table's
sCapHeight) over its units per em (its head table'sunitsPerEm), read once from the font file.final - child → Widget?
-
The widget below this widget in the tree.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → SingleChildRenderObjectElement -
RenderObjectWidgets always inflate to a RenderObjectElement subclass.
inherited
-
createRenderObject(
BuildContext context) → RenderDesignCapCenter -
Creates an instance of the RenderObject class that this
RenderObjectWidget represents, using the configuration described by this
RenderObjectWidget.
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.
override
-
didUnmountRenderObject(
covariant RenderObject renderObject) → void -
This method is called when a RenderObject that was previously
associated with this widget is removed from the render tree.
The provided RenderObject will be of the same type as the one created by
this widget's createRenderObject method.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
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
-
updateRenderObject(
BuildContext context, covariant RenderDesignCapCenter renderObject) → void -
Copies the configuration described by this RenderObjectWidget to the
given RenderObject, which will be of the same type as returned by this
object's createRenderObject.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited