build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Describes the part of the user interface represented by this widget.

The framework calls this method when this widget is inserted into the tree in a given BuildContext and when the dependencies of this widget change (e.g., an InheritedWidget referenced by this widget changes). This method can potentially be called in every frame and should not have any side effects beyond building a widget.

The framework replaces the subtree below this widget with the widget returned by this method, either by updating the existing subtree or by removing the subtree and inflating a new subtree, depending on whether the widget returned by this method can update the root of the existing subtree, as determined by calling Widget.canUpdate.

Typically implementations return a newly created constellation of widgets that are configured with information from this widget's constructor and from the given BuildContext.

The given BuildContext contains information about the location in the tree at which this widget is being built. For example, the context provides the set of inherited widgets for this location in the tree. A given widget might be built with multiple different BuildContext arguments over time if the widget is moved around the tree or if the widget is inserted into the tree in multiple places at once.

The implementation of this method must only depend on:

If a widget's build method is to depend on anything else, use a StatefulWidget instead.

See also:

  • StatelessWidget, which contains the discussion on performance considerations.

Implementation

@override
widgets.Widget build(widgets.BuildContext context) => SvgPicture.string(
      '''
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M34.4836 14.9955C33.2411 11.4989 29.8956 9 25.9679 9H22.0321C17.0593 9 13 13.014 13 18V30C13 34.986 17.0593 39 22.0321 39H25.9679C30.9407 39 35 34.986 35 30C35 25.014 30.9407 21 25.9679 21H22.0321C20.9701 21 19.949 21.1833 19 21.5203V18C19 16.3575 20.3432 15 22.0321 15H25.9679C27.2943 15 28.4167 15.8415 28.8299 17.0045C29.3847 18.5657 31.1 19.3816 32.6613 18.8268C34.2225 18.2721 35.0384 16.5567 34.4836 14.9955ZM25.9679 11C29.0275 11 31.6326 12.9455 32.599 15.6652C32.784 16.1856 32.512 16.7574 31.9916 16.9423C31.4712 17.1272 30.8994 16.8552 30.7145 16.3348C30.0243 14.3925 28.1598 13 25.9679 13H22.0321C19.2472 13 17 15.2444 17 18V23.0799C17 23.4374 17.1909 23.7677 17.5006 23.9463C17.8104 24.1248 18.1918 24.1244 18.5012 23.9453C19.539 23.3442 20.7446 23 22.0321 23H25.9679C29.847 23 33 26.1294 33 30C33 33.8706 29.847 37 25.9679 37H22.0321C18.1531 37 15 33.8706 15 30V18C15 14.1294 18.1531 11 22.0321 11H25.9679ZM25.9679 27C27.6568 27 29 28.3575 29 30C29 31.6425 27.6568 33 25.9679 33H22.0321C20.3432 33 19 31.6425 19 30C19 28.3575 20.3432 27 22.0321 27H25.9679ZM31 30C31 27.2444 28.7529 25 25.9679 25H22.0321C19.2472 25 17 27.2444 17 30C17 32.7556 19.2472 35 22.0321 35H25.9679C28.7529 35 31 32.7556 31 30Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );