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="M35 18C35 13.0294 30.9706 9 26 9H22C18.0761 9 14.7468 11.5093 13.5129 15.0003C12.9608 16.5624 13.7795 18.2764 15.3417 18.8285C16.9038 19.3807 18.6178 18.5619 19.1699 16.9997C19.5828 15.8315 20.6974 15 22 15H26C27.6569 15 29 16.3431 29 18C29 18.8886 28.6175 19.6835 27.9993 20.2368C27.9708 20.2623 27.9428 20.2883 27.9154 20.3148L13.9154 33.8426C13.0361 34.6923 12.7604 35.9906 13.2186 37.1242C13.6768 38.2579 14.7772 39 16 39H32C33.6569 39 35 37.6569 35 36C35 34.3431 33.6569 33 32 33H23.422L32.0476 24.6654C33.8568 23.0232 35 20.6432 35 18ZM26 11C29.866 11 33 14.134 33 18C33 20.0602 32.1088 21.9137 30.6935 23.1934C30.6854 23.2008 30.6773 23.2083 30.6694 23.216L20.2532 33.2809C19.96 33.5641 19.8682 33.9969 20.0209 34.3747C20.1736 34.7526 20.5404 35 20.948 35H32C32.5523 35 33 35.4477 33 36C33 36.5523 32.5523 37 32 37H16C15.5924 37 15.2256 36.7526 15.0729 36.3747C14.9201 35.9969 15.012 35.5641 15.3051 35.2809L29.3051 21.7531L28.6103 21.034L29.3051 21.7531C29.3143 21.7442 29.3236 21.7356 29.3331 21.7271L29.3331 21.7271C30.3579 20.8098 31 19.4803 31 18C31 15.2386 28.7614 13 26 13H22C19.8256 13 17.9715 14.3889 17.2843 16.3332C17.1002 16.854 16.5289 17.1269 16.0082 16.9428C15.4874 16.7588 15.2145 16.1875 15.3986 15.6668C16.3592 12.9488 18.9511 11 22 11H26Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );