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="M17 24C20.8675 24 24 20.8675 24 17C24 13.1325 20.8675 10 17 10C13.1325 10 10 13.1325 10 17C10 20.8675 13.1325 24 17 24ZM22 17C22 19.7629 19.7629 22 17 22C14.2371 22 12 19.7629 12 17C12 14.2371 14.2371 12 17 12C19.7629 12 22 14.2371 22 17Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 38V32.4C4 28.144 12.6612 26 17 26C19.8862 26 24.6851 26.9487 27.5749 28.8368C29.6346 28.2798 31.8936 28 33.5 28C35.3579 28 37.851 28.3742 39.9092 29.1307C40.9364 29.5084 41.9189 30.004 42.6622 30.6463C43.4108 31.2931 44 32.1676 44 33.2667V38H4ZM6 32.4C6 32.0826 6.14556 31.6486 6.76618 31.0846C7.39908 30.5095 8.37322 29.9511 9.60682 29.4645C12.076 28.4906 15.0766 28 17 28C18.9234 28 21.924 28.4906 24.3932 29.4645C25.6268 29.9511 26.6009 30.5095 27.2338 31.0846C27.8544 31.6486 28 32.0826 28 32.4V36H6V32.4ZM29.3532 30.4692C30.8657 30.1565 32.3834 30 33.5 30C35.1465 30 37.4034 30.3405 39.2191 31.0079C40.1288 31.3423 40.8643 31.736 41.3546 32.1597C41.8398 32.5789 42 32.947 42 33.2667V36H30V32.4C30 31.6991 29.7651 31.0554 29.3532 30.4692Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M39 20.5C39 23.5387 36.5387 26 33.5 26C30.4613 26 28 23.5387 28 20.5C28 17.4612 30.4613 15 33.5 15C36.5387 15 39 17.4612 39 20.5ZM33.5 24C35.4342 24 37 22.4342 37 20.5C37 18.5658 35.4342 17 33.5 17C31.5658 17 30 18.5658 30 20.5C30 22.4342 31.5658 24 33.5 24Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );