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="M10 8.58582L39.4142 38L38 39.4142L8.58579 10L10 8.58582Z" fill="black"/>
<path d="M7 32C6.44772 32 6 32.4477 6 33V35C6 35.5523 6.44772 36 7 36H31C31.5523 36 32 36.4477 32 37C32 37.5523 31.5523 38 31 38H7C5.34315 38 4 36.6569 4 35V33C4 31.3431 5.34315 30 7 30H25.5C26.0523 30 26.5 30.4477 26.5 31C26.5 31.5523 26.0523 32 25.5 32H7Z" fill="black"/>
<path d="M40 32C40 31.4477 39.5523 31 39 31C38.4477 31 38 31.4477 38 32V34C38 34.5523 38.4477 35 39 35C39.5523 35 40 34.5523 40 34V32Z" fill="black"/>
<path d="M34 17C32.3431 17 31 18.3431 31 20V21.8182C31 23.475 32.3431 24.8182 34 24.8182H37C38.6569 24.8182 40 26.1613 40 27.8182V28C40 28.5523 39.5523 29 39 29C38.4477 29 38 28.5523 38 28V27.8182C38 27.2659 37.5523 26.8182 37 26.8182H34C31.2386 26.8182 29 24.5796 29 21.8182V20C29 17.2386 31.2386 15 34 15C34.5523 15 35 15.4477 35 16C35 16.5523 34.5523 17 34 17Z" fill="black"/>
<path d="M38 19C37.4477 19 37 19.4477 37 20C37 20.5523 37.4477 21 38 21C40.2091 21 42 22.7909 42 25V28C42 28.5523 42.4477 29 43 29C43.5523 29 44 28.5523 44 28V25C44 22.9294 42.9512 21.1039 41.3559 20.0255C42.3585 19.2173 43 17.979 43 16.5909V15C43 12.2386 40.7614 10 38 10C37.4477 10 37 10.4477 37 11C37 11.5523 37.4477 12 38 12C39.6569 12 41 13.3431 41 15V16.5909C41 17.9214 39.9214 19 38.5909 19H38Z" fill="black"/>
<path d="M44 32C44 31.4477 43.5523 31 43 31C42.4477 31 42 31.4477 42 32V36C42 36.5523 42.4477 37 43 37C43.5523 37 44 36.5523 44 36V32Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );