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="M24 27C28.4183 27 32 23.4183 32 19C32 14.5817 28.4183 11 24 11C19.5817 11 16 14.5817 16 19C16 23.4183 19.5817 27 24 27ZM24 25C27.3137 25 30 22.3137 30 19C30 15.6863 27.3137 13 24 13C20.6863 13 18 15.6863 18 19C18 22.3137 20.6863 25 24 25Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M44 24C44 35.0457 35.0457 44 24 44C12.9543 44 4 35.0457 4 24C4 12.9543 12.9543 4 24 4C35.0457 4 44 12.9543 44 24ZM33.6305 39.2097C30.8457 40.9768 27.5423 42 24 42C20.3721 42 16.9948 40.9267 14.1685 39.0803C13.9285 38.7804 13.6852 38.4703 13.4386 38.15C13.1554 37.7823 13 37.32 13 36.8449C13 35.7682 13.7739 34.8648 14.8088 34.7137C21.6538 33.7141 26.367 33.8003 33.221 34.749C34.2376 34.8897 35 35.77 35 36.8177C35 37.2976 34.8349 37.7641 34.537 38.1273C34.2296 38.5021 33.9276 38.8628 33.6305 39.2097ZM36.985 36.4656C36.8253 34.5938 35.4036 33.032 33.4952 32.7679C26.4791 31.7968 21.5747 31.7044 14.5198 32.7347C12.5995 33.0151 11.1855 34.5913 11.0169 36.4675C7.90982 33.2328 6 28.8394 6 24C6 14.0589 14.0589 6 24 6C33.9411 6 42 14.0589 42 24C42 28.8385 40.091 33.231 36.985 36.4656Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );