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" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 1.25C6.06294 1.25 1.25 6.06294 1.25 12C1.25 17.937 6.06293 22.75 12 22.75C17.937 22.75 22.75 17.937 22.75 12C22.75 6.06293 17.937 1.25 12 1.25ZM12.75 5.5C12.75 5.08579 12.4142 4.75 12 4.75C11.5858 4.75 11.25 5.08579 11.25 5.5V6.60325C10.7348 6.6798 10.2303 6.85793 9.8025 7.18193C9.13016 7.69119 8.75 8.48349 8.75 9.50001C8.75 9.99538 8.86527 10.4357 9.09233 10.8161C9.31679 11.1921 9.62636 11.4694 9.95672 11.6796C10.5694 12.0695 11.3505 12.2823 11.9957 12.4581L12.0527 12.4736C12.772 12.6697 13.3375 12.831 13.738 13.0859C13.9232 13.2038 14.0434 13.3249 14.1197 13.4528C14.1934 13.5763 14.25 13.7454 14.25 14C14.25 14.6092 14.0047 14.9921 13.6458 15.2435C13.2567 15.516 12.681 15.665 12.0269 15.6415C11.0251 15.6055 10.0709 15.1779 9.6 14.55C9.35147 14.2186 8.88137 14.1515 8.55 14.4C8.21863 14.6485 8.15147 15.1186 8.4 15.45C9.06955 16.3427 10.1574 16.875 11.25 17.0647V18.5C11.25 18.9142 11.5858 19.25 12 19.25C12.4142 19.25 12.75 18.9142 12.75 18.5V17.109C13.3777 17.0337 13.9915 16.8327 14.5063 16.4721C15.2634 15.942 15.75 15.1018 15.75 14C15.75 13.5046 15.6347 13.0644 15.4077 12.684C15.1832 12.3079 14.8736 12.0306 14.5433 11.8204C13.9306 11.4305 13.1495 11.2177 12.5043 11.0419L12.5043 11.0419L12.4473 11.0264C11.728 10.8303 11.1625 10.669 10.762 10.4141C10.5768 10.2962 10.4566 10.1751 10.3803 10.0472C10.3066 9.92373 10.25 9.75463 10.25 9.50001C10.25 8.8865 10.4603 8.56541 10.7082 8.37765C10.9874 8.16615 11.4239 8.04349 11.9798 8.05845C12.9286 8.08398 13.9414 8.50209 14.4697 9.03033C14.7626 9.32323 15.2374 9.32322 15.5303 9.03033C15.8232 8.73743 15.8232 8.26256 15.5303 7.96967C14.8479 7.28726 13.7987 6.80659 12.75 6.63088V5.5Z" fill="currentColor"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );