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 d="M16 15C16 14.4477 16.4477 14 17 14C17.5523 14 18 14.4477 18 15V17.4302L21 19.9907V15C21 14.4477 21.4477 14 22 14C22.5523 14 23 14.4477 23 15V21.6978L26 24.2583V15C26 14.4477 26.4477 14 27 14C27.5523 14 28 14.4477 28 15V25.9654L31 28.5259V15C31 14.4477 31.4477 14 32 14C32.5523 14 33 14.4477 33 15V30.233L36.1192 32.8952L34.8208 34.4165L33 32.8624V33C33 33.5523 32.5523 34 32 34C31.4477 34 31 33.5523 31 33V31.1554L28 28.5948V33C28 33.5523 27.5523 34 27 34C26.4477 34 26 33.5523 26 33V26.8878L23 24.3272V33C23 33.5523 22.5523 34 22 34C21.4477 34 21 33.5523 21 33V22.6202L18 20.0596V33C18 33.5523 17.5523 34 17 34C16.4477 34 16 33.5523 16 33V18.3526L12.2334 15.1377L13.5318 13.6165L16 15.7231V15Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24.157 44C35.2027 44 44.157 35.0457 44.157 24C44.157 12.9543 35.2027 4 24.157 4C13.1113 4 4.15698 12.9543 4.15698 24C4.15698 35.0457 13.1113 44 24.157 44ZM24.157 42C34.0981 42 42.157 33.9411 42.157 24C42.157 14.0589 34.0981 6 24.157 6C14.2159 6 6.15698 14.0589 6.15698 24C6.15698 33.9411 14.2159 42 24.157 42Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );