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="M20.0001 6H28.0001V6.7335C28.6179 13.6002 30.662 14.8428 36.8981 11.9345L37.5885 11.5359L41.5885 18.4641L41.1985 18.6893C35.2937 22.7886 35.2333 25.1979 41.1318 29.2722L41.5885 29.5359L41.5689 29.5699L37.5885 36.4641L36.8271 36.0245C30.4716 33.1184 28.5347 34.548 28.0271 42.0249L28.0001 41.6958V42H20.0001V40.8335C19.3297 34.2078 17.1809 33.1931 10.8459 36.2134L10.4116 36.4641L6.41162 29.5359L7.44679 28.9383C12.6856 25.1559 12.6838 22.7927 7.34432 19.0026L6.41162 18.4641L10.4116 11.5359L10.6347 11.6647C17.1052 14.7619 19.3341 13.8313 20.0001 7.20194V6ZM29.0001 24C29.0001 26.7614 26.7615 29 24.0001 29C21.2387 29 19.0001 26.7614 19.0001 24C19.0001 21.2386 21.2387 19 24.0001 19C26.7615 19 29.0001 21.2386 29.0001 24ZM32.0001 24C32.0001 28.4183 28.4184 32 24.0001 32C19.5818 32 16.0001 28.4183 16.0001 24C16.0001 19.5817 19.5818 16 24.0001 16C28.4184 16 32.0001 19.5817 32.0001 24ZM34.0001 24C34.0001 29.5228 29.523 34 24.0001 34C18.4773 34 14.0001 29.5228 14.0001 24C14.0001 18.4772 18.4773 14 24.0001 14C29.523 14 34.0001 18.4772 34.0001 24Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );