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 18C27.866 18 31 14.866 31 11C31 7.13401 27.866 4 24 4C20.134 4 17 7.13401 17 11C17 14.866 20.134 18 24 18ZM24 16C26.7614 16 29 13.7614 29 11C29 8.23858 26.7614 6 24 6C21.2386 6 19 8.23858 19 11C19 13.7614 21.2386 16 24 16Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M26.7423 34.3302L21.5529 32.7568V29.4992C21.5529 28.9469 21.1052 28.4992 20.5529 28.4992C20.0007 28.4992 19.5529 28.9469 19.5529 29.4992V33.4986C19.5529 33.9159 19.8119 34.287 20.1975 34.4333L21.951 35.0985L20.4215 36.1838C20.3015 36.269 20.2026 36.3796 20.1308 36.5058L21.5495 38.3974C22.7094 39.9437 22.3961 42.1376 20.8497 43.2974C19.3034 44.4573 17.1096 44.144 15.9497 42.5976L10.7001 35.5987C9.88958 34.5181 9.77325 33.0675 10.4012 31.8716L14.3677 24.3169C15.028 23.0592 16.2435 22.1871 17.6465 21.9644L29.7501 20.0434C31.2325 19.8081 32.6999 20.5442 33.3976 21.8731L37.5973 29.8719C38.2253 31.0678 38.1089 32.5184 37.2984 33.599L32.0488 40.5979C30.8889 42.1443 28.6951 42.4576 27.1488 41.2977C25.6024 40.1379 25.2891 37.9441 26.4489 36.3977L27.6755 34.7624C27.5828 34.6778 27.4746 34.6109 27.3564 34.5656L26.7423 34.3302ZM31.229 33.6846L30.0044 34.9889L30.0048 34.9901L28.0489 37.5978C27.5518 38.2605 27.6861 39.2007 28.3488 39.6978C29.0115 40.1949 29.9517 40.0606 30.4488 39.3979L35.6984 32.3989C36.0458 31.9358 36.0957 31.3142 35.8266 30.8016L31.6269 22.8028C31.3278 22.2333 30.699 21.9178 30.0637 22.0187L17.96 23.9397C17.1806 24.0634 16.5053 24.5479 16.1384 25.2467L12.1719 32.8013C11.9028 33.3138 11.9527 33.9355 12.3001 34.3986L17.5497 41.3975C18.0467 42.0603 18.987 42.1945 19.6497 41.6975C20.3124 41.2004 20.4467 40.2602 19.9496 39.5975L17.9703 36.9586L17.9716 36.9502L16.2015 34.602L17.5541 33.5824C17.5533 33.5545 17.5529 33.5266 17.5529 33.4986V29.4992C17.5529 27.8424 18.8961 26.4992 20.5529 26.4992C22.2098 26.4992 23.5529 27.8424 23.5529 29.4992V31.2733L25.7102 31.9274C25.2607 31.227 25 30.394 25 29.5C25 27.0147 27.0147 25 29.5 25C31.9853 25 34 27.0147 34 29.5C34 31.3808 32.8462 32.9921 31.2078 33.6646L31.229 33.6846ZM27 29.5C27 28.1193 28.1193 27 29.5 27C30.8807 27 32 28.1193 32 29.5C32 30.8807 30.8807 32 29.5 32C28.1193 32 27 30.8807 27 29.5Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );