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="M35 18C35 13.014 30.9407 9 25.9679 9H22.0321C17.0593 9 13 13.014 13 18C13 20.3085 13.8718 22.4104 15.2998 24C13.8718 25.5896 13 27.6915 13 30C13 34.986 17.0593 39 22.0321 39H25.9679C30.9407 39 35 34.986 35 30C35 27.6915 34.1283 25.5896 32.7002 24C34.1283 22.4104 35 20.3085 35 18ZM25.9679 11C29.847 11 33 14.1294 33 18C33 20.0924 32.0807 21.9657 30.6206 23.2488C30.4045 23.4387 30.2806 23.7124 30.2806 24C30.2806 24.2876 30.4045 24.5613 30.6206 24.7512C32.0807 26.0343 33 27.9076 33 30C33 33.8706 29.847 37 25.9679 37H22.0321C18.1531 37 15 33.8706 15 30C15 27.9076 15.9193 26.0343 17.3795 24.7512C17.5956 24.5613 17.7194 24.2876 17.7194 24C17.7194 23.7124 17.5956 23.4387 17.3795 23.2488C15.9193 21.9657 15 20.0924 15 18C15 14.1294 18.1531 11 22.0321 11H25.9679ZM25.9679 15C27.6568 15 29 16.3575 29 18C29 19.6425 27.6568 21 25.9679 21H22.0321C20.3432 21 19 19.6425 19 18C19 16.3575 20.3432 15 22.0321 15H25.9679ZM31 18C31 15.2444 28.7529 13 25.9679 13H22.0321C19.2472 13 17 15.2444 17 18C17 20.7556 19.2472 23 22.0321 23H25.9679C28.7529 23 31 20.7556 31 18ZM25.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,
    );