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="M32 9C32 7.34315 33.3431 6 35 6H39C40.6569 6 42 7.34315 42 9V39C42 40.6569 40.6569 42 39 42H35C33.3431 42 32 40.6569 32 39V9ZM35 8C34.4477 8 34 8.44772 34 9V10.1716L36.1716 8H35ZM39 8L34 13V15.1716L40 9.17156V9C40 8.44772 39.5523 8 39 8ZM40 12L34 18V20.1716L40 14.1716V12ZM40 17L34 23V25.1716L40 19.1716V17ZM40 22L34 28V30.1716L40 24.1716V22ZM40 27L34 33V35.1716L40 29.1716V27ZM40 32L34 38V39C34 39.3199 34.1502 39.6046 34.3838 39.7877L40 34.1715V32ZM40 37L37 40H39C39.5523 40 40 39.5523 40 39V37Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19 21C19 19.3431 20.3431 18 22 18H26C27.6569 18 29 19.3431 29 21V39C29 40.6569 27.6569 42 26 42H22C20.3431 42 19 40.6569 19 39V21ZM24 20H26C26.0541 20 26.1072 20.0043 26.159 20.0126L21 25.1716V23L24 20ZM21 30.1716V28L27 22V24.1716L21 30.1716ZM27 29.1716V27L21 33V35.1716L27 29.1716ZM21 39V38L27 32V34.1717L21.3839 39.7877C21.1502 39.6047 21 39.3199 21 39ZM24.0001 40L27 37.0001V39C27 39.5523 26.5523 40 26 40H24.0001Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 30C7.34315 30 6 31.3431 6 33V39C6 40.6569 7.34315 42 9 42H13C14.6569 42 16 40.6569 16 39V33C16 31.3431 14.6569 30 13 30H9ZM8 33C8 32.4477 8.44772 32 9 32H11.1716L8 35.1716V33ZM8 38L13.7071 32.2929C13.8881 32.4739 14 32.7239 14 33V34.1716L8.38389 39.7877C8.15019 39.6047 8 39.3199 8 39V38ZM11 40H13C13.5523 40 14 39.5523 14 39V37L11 40Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );