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="M14 18C14 14.6863 16.6863 12 20 12C23.3137 12 26 14.6863 26 18C26 21.3137 23.3137 24 20 24C16.6863 24 14 21.3137 14 18ZM20 14C17.7909 14 16 15.7909 16 18C16 20.2091 17.7909 22 20 22C22.2091 22 24 20.2091 24 18C24 15.7909 22.2091 14 20 14Z" fill="black"/>
<path d="M28 17C27.4477 17 27 17.4477 27 18C27 18.5523 27.4477 19 28 19H29.5V20.5C29.5 21.0523 29.9477 21.5 30.5 21.5C31.0523 21.5 31.5 21.0523 31.5 20.5V19H33C33.5523 19 34 18.5523 34 18C34 17.4477 33.5523 17 33 17H31.5V15.5C31.5 14.9477 31.0523 14.5 30.5 14.5C29.9477 14.5 29.5 14.9477 29.5 15.5V17H28Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 34.0306C10 36.2228 11.7909 38 14 38H18V40H23V44H25V40H30V38H34C36.2091 38 38 36.2228 38 34.0306V10.3273C38 8.13508 36.2091 6.3579 34 6.3579H28L26.868 5.20243C25.2973 3.59919 22.7027 3.59919 21.132 5.20243L20 6.3579H14C11.7909 6.3579 10 8.13507 10 10.3273V34.0306ZM28 8.3579C27.4625 8.3579 26.9475 8.14152 26.5714 7.75754L25.4393 6.60207C24.6529 5.79931 23.3471 5.79931 22.5607 6.60207L21.4286 7.75754C21.0525 8.14151 20.5375 8.3579 20 8.3579H14C12.8809 8.3579 12 9.25408 12 10.3273V28.971C13.3017 28.9498 14.5326 28.9875 15.7005 29.0306C15.8789 29.0372 16.0555 29.0439 16.2306 29.0505C17.514 29.0991 18.711 29.1444 19.8818 29.1195C22.5089 29.0636 24.924 28.6538 27.4919 27.1387C30.6105 25.2987 33.2501 25.8514 35.0748 26.9133C35.4135 27.1104 35.7222 27.3234 36 27.5388V10.3273C36 9.25408 35.1191 8.3579 34 8.3579H28ZM36 30.3295C35.9122 30.2186 35.7913 30.0741 35.6392 29.9109C35.2727 29.5177 34.7407 29.0328 34.0689 28.6419C32.7749 27.8889 30.9145 27.4415 28.5081 28.8613C25.551 30.606 22.766 31.0586 19.9243 31.1191C18.6899 31.1453 17.4295 31.0975 16.1531 31.049C15.9779 31.0424 15.8025 31.0357 15.6267 31.0292C14.4539 30.986 13.2549 30.9499 12 30.9713V34.0306C12 35.1038 12.8809 36 14 36H34C35.1191 36 36 35.1038 36 34.0306V30.3295Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );