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="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 12.25C11.0054 12.25 10.0516 12.6451 9.34835 13.3483C8.64509 14.0516 8.25 15.0054 8.25 16V16.75H15.75V16C15.75 15.0054 15.3549 14.0516 14.6517 13.3483C13.9484 12.6451 12.9946 12.25 12 12.25ZM10.409 14.409C10.831 13.9871 11.4033 13.75 12 13.75C12.5967 13.75 13.169 13.9871 13.591 14.409C13.8305 14.6486 14.0105 14.9366 14.1213 15.25H9.87868C9.9895 14.9366 10.1695 14.6486 10.409 14.409Z" fill="black"/>
<path d="M7.83542 7.82934C7.46494 7.6441 7.01443 7.79427 6.82919 8.16475C6.64395 8.53524 6.79412 8.98574 7.1646 9.17098L8.37575 9.77656C8.56001 9.86869 8.56001 10.1316 8.37575 10.2238L7.1646 10.8293C6.79412 11.0146 6.64395 11.4651 6.82919 11.8356C7.01443 12.2061 7.46494 12.3562 7.83542 12.171L9.04657 11.5654C10.3364 10.9205 10.3364 9.07983 9.04657 8.43492L7.83542 7.82934Z" fill="black"/>
<path d="M16.1646 7.82934C16.5351 7.6441 16.9856 7.79427 17.1708 8.16475C17.3561 8.53524 17.2059 8.98574 16.8354 9.17098L15.6243 9.77656C15.44 9.86869 15.44 10.1316 15.6243 10.2238L16.8354 10.8293C17.2059 11.0146 17.3561 11.4651 17.1708 11.8356C16.9856 12.2061 16.5351 12.3562 16.1646 12.171L14.9535 11.5654C13.6636 10.9205 13.6636 9.07983 14.9535 8.43492L16.1646 7.82934Z" fill="black"/>
<path d="M15 7C15 7.55228 14.5523 8 14 8C13.4477 8 13 7.55228 13 7C13 6.44772 13.4477 6 14 6C14.5523 6 15 6.44772 15 7Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM10.0021 4.25149C10.6407 4.08731 11.3102 4 12 4C16.4183 4 20 7.58172 20 12C20 12.7241 19.9038 13.4257 19.7235 14.0928C19.5774 14.033 19.4176 14 19.25 14C18.5596 14 18 14.5596 18 15.25C18 15.7431 18.2855 16.1695 18.7002 16.3729C17.2718 18.557 14.8044 20 12 20C12 19.4477 11.5523 19 11 19C10.532 19 10.1391 19.3215 10.0301 19.7556C8.10852 19.2691 6.46406 18.0871 5.38012 16.4933C6.00933 16.4282 6.5 15.8964 6.5 15.25C6.5 14.5596 5.94036 14 5.25 14C4.90076 14 4.58497 14.1432 4.35817 14.3741C4.12538 13.624 4 12.8267 4 12C4 9.03309 5.61508 6.4434 8.01402 5.06217C8.00479 5.12343 8 5.18616 8 5.25C8 5.94036 8.55964 6.5 9.25 6.5C9.94036 6.5 10.5 5.94036 10.5 5.25C10.5 4.84199 10.3045 4.47964 10.0021 4.25149Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );