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="M37 10C37 9.44772 36.5523 9 36 9C35.4477 9 35 9.44772 35 10V12.3028L36.1679 14.0547C36.4743 14.5142 37.0952 14.6384 37.5547 14.3321C38.0142 14.0257 38.1384 13.4048 37.8321 12.9453L37 11.6972V10Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M36 18C39.3137 18 42 15.3137 42 12C42 8.68629 39.3137 6 36 6C32.6863 6 30 8.68629 30 12C30 15.3137 32.6863 18 36 18ZM36 16C38.2091 16 40 14.2091 40 12C40 9.79086 38.2091 8 36 8C33.7909 8 32 9.79086 32 12C32 14.2091 33.7909 16 36 16Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18.0961 15.1052C16.624 13.6323 14.2364 13.6315 12.7632 15.1034L12.0591 15.8069C10.7199 15.4263 9.22155 15.7669 8.16703 16.8285C6.61099 18.3951 6.61099 20.9376 8.16703 22.5042L9 23.3428V34H6V36H9.05051C8.40223 36.6353 8 37.5207 8 38.5C8 40.433 9.567 42 11.5 42C13.433 42 15 40.433 15 38.5C15 37.5207 14.5978 36.6353 13.9495 36H34.0505C33.4022 36.6353 33 37.5207 33 38.5C33 40.433 34.567 42 36.5 42C38.433 42 40 40.433 40 38.5C40 37.5207 39.5978 36.6353 38.9495 36H42V34H38V30.9997H38.0662C40.2388 30.9997 42 29.2238 42 27.033C42 24.8423 40.2388 23.0664 38.0662 23.0664H20.11C20.0285 23.0664 19.9502 23.0337 19.8925 22.9756L19.5261 22.6068L19.8945 22.2387C21.3678 20.7667 21.3686 18.3793 19.8963 16.9063L18.0961 15.1052ZM36 34V30.9997H17.0722C16.7733 30.9997 16.4867 30.8801 16.2752 30.6672L11 25.3563V34H36ZM18.1167 21.1878L18.4809 20.8239C19.1727 20.1327 19.1731 19.0118 18.4818 18.3202L16.6816 16.5191C15.9902 15.8273 14.8687 15.8269 14.1768 16.5182L13.8263 16.8684L18.1167 21.1878ZM38.0662 25.0664H20.11C19.4932 25.0664 18.905 24.8194 18.4736 24.3851L12.3677 18.238C11.5973 17.4623 10.3564 17.4623 9.586 18.238C8.80467 19.0246 8.80467 20.3081 9.586 21.0948L17.4379 28.9997H38.0662C39.1186 28.9997 40 28.1349 40 27.033C40 25.9311 39.1185 25.0664 38.0662 25.0664ZM13 38.5C13 39.3284 12.3284 40 11.5 40C10.6716 40 10 39.3284 10 38.5C10 37.6716 10.6716 37 11.5 37C12.3284 37 13 37.6716 13 38.5ZM36.5 40C37.3284 40 38 39.3284 38 38.5C38 37.6716 37.3284 37 36.5 37C35.6716 37 35 37.6716 35 38.5C35 39.3284 35.6716 40 36.5 40Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );