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="M9.17647 8.5C7.42215 8.5 6 9.93908 6 11.7143V31C6 32.7752 7.42215 34.2143 9.17647 34.2143H19.7646V36.3571H15.5293V38.5H32.4705V36.3571H28.2353V34.2143H38.8235C40.5778 34.2143 42 32.7752 42 31V11.7143C42 9.93908 40.5778 8.5 38.8235 8.5H9.17647ZM21.8823 36.3571H26.1177V34.2143H21.8823V36.3571ZM8.11765 11.7143C8.11765 11.1226 8.5917 10.6429 9.17647 10.6429H38.8235C39.4083 10.6429 39.8824 11.1226 39.8824 11.7143V31C39.8824 31.5917 39.4083 32.0714 38.8235 32.0714H9.17647C8.5917 32.0714 8.11765 31.5917 8.11765 31V11.7143ZM15.5293 12.7857H13.4116V14.9286H11.294L11.294 17.0714H13.4116V19.2143H15.5293V17.0714H17.647V14.9286H15.5293V12.7857ZM12.3528 21.3571C11.768 21.3571 11.2939 21.8368 11.2939 22.4286V26.7143C11.2939 27.306 11.768 27.7857 12.3528 27.7857H16.5881C17.1728 27.7857 17.6469 27.306 17.6469 26.7143V22.4286C17.6469 21.8368 17.1728 21.3571 16.5881 21.3571H12.3528ZM13.4116 25.6429V23.5H15.5292V25.6429H13.4116ZM20.8237 13.8571C20.8237 13.2654 21.2978 12.7857 21.8826 12.7857H26.1178C26.7026 12.7857 27.1767 13.2654 27.1767 13.8571V18.1429C27.1767 18.7346 26.7026 19.2143 26.1178 19.2143H21.8826C21.2978 19.2143 20.8237 18.7346 20.8237 18.1429V13.8571ZM22.9414 14.9286V17.0714H25.059V14.9286H22.9414ZM21.8826 21.3571C21.2978 21.3571 20.8237 21.8368 20.8237 22.4286V26.7143C20.8237 27.306 21.2978 27.7857 21.8826 27.7857H26.1178C26.7026 27.7857 27.1767 27.306 27.1767 26.7143V22.4286C27.1767 21.8368 26.7026 21.3571 26.1178 21.3571H21.8826ZM22.9414 25.6429V23.5H25.059V25.6429H22.9414ZM30.353 13.8571C30.353 13.2654 30.8271 12.7857 31.4118 12.7857H35.6471C36.2319 12.7857 36.706 13.2654 36.706 13.8571V18.1429C36.706 18.7346 36.2319 19.2143 35.6471 19.2143H31.4118C30.8271 19.2143 30.353 18.7346 30.353 18.1429V13.8571ZM32.4707 14.9286V17.0714H34.5883V14.9286H32.4707Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );