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 d="M26.2 4C27.8569 4 29.2 5.34315 29.2 7V11.8769C29.2 12.7103 28.9144 13.5172 28.3634 14.1676C27.8644 14.7568 27.2732 15.0716 26.8522 15.2434C26.064 15.565 25.2071 15.6459 24.6429 15.6823C24.0379 15.7213 23.36 15.7259 22.7505 15.73L22.6768 15.7305C22.0123 15.735 21.379 15.7403 20.7581 15.7731C19.4258 15.8434 18.6096 16.0283 18.1898 16.258C18.1063 16.3037 18.066 16.3367 18.0494 16.3529C18.2255 16.4205 18.4631 16.4925 18.7744 16.5615C20.1924 16.8759 22.1332 16.9383 24.5214 17.015L25.0984 17.0337C27.5102 17.1128 30.4236 17.2279 32.7451 17.9315C33.9361 18.2925 35.2493 18.8848 36.2859 19.9451C37.4045 21.0894 38 22.5752 38 24.2615C38 26.0512 37.289 27.5996 35.9694 28.6936C34.7921 29.6696 33.3442 30.1067 32.0942 30.3318C29.6993 30.7631 26.6763 30.622 24.1036 30.502L23.8608 30.4907C20.9864 30.3572 18.6275 30.2662 16.9768 30.5678C16.5988 30.6369 16.3228 30.7168 16.1294 30.793C16.0783 30.8131 16.036 30.8318 16.0014 30.8484C16.0073 31.0329 16.0307 31.1524 16.05 31.222C16.0712 31.2982 16.0916 31.3299 16.0979 31.3392C16.1027 31.3466 16.1605 31.4351 16.4274 31.5525C17.1024 31.8497 18.2904 31.9881 20.0269 31.9458C20.8178 31.9265 21.6166 31.8753 22.4349 31.8228L22.5152 31.8176C23.3257 31.7657 24.1994 31.7102 24.9757 31.7087C25.6783 31.7074 26.6714 31.741 27.5724 32.0533C28.0523 32.2196 28.7205 32.5362 29.2823 33.168C29.9031 33.8661 30.2 34.7318 30.2 35.6V41C30.2 42.6569 28.8569 44 27.2 44C25.5431 44 24.2 42.6569 24.2 41V37.73C23.8169 37.7474 23.3863 37.7741 22.8989 37.8054L22.7825 37.8128C21.9917 37.8636 21.0862 37.9217 20.1731 37.944C18.3596 37.9882 15.9976 37.9189 14.0101 37.0441C12.9513 36.578 11.8965 35.8407 11.1227 34.6929C10.3429 33.5363 10 32.1874 10 30.759C10 28.9705 10.7056 27.4201 12.0214 26.3204C13.1974 25.3374 14.6457 24.8945 15.8982 24.6656C18.3073 24.2254 21.3485 24.3671 23.9305 24.4874L24.1392 24.4971C27.0156 24.6307 29.3764 24.7247 31.0308 24.4268C31.4096 24.3586 31.6864 24.2794 31.8804 24.2038C31.9247 24.1865 31.9624 24.1703 31.9942 24.1556C31.9932 24.1475 31.9921 24.1407 31.9911 24.1351C31.9264 24.0716 31.6729 23.8761 31.0049 23.6736C29.5764 23.2407 27.4898 23.1154 24.9016 23.0304C24.673 23.0229 24.4395 23.0158 24.2022 23.0085H24.2022C22.0041 22.941 19.4789 22.8634 17.4756 22.4193C16.3536 22.1705 15.042 21.7394 13.9659 20.8637C12.7503 19.8745 12 18.4449 12 16.7179C12 15.4732 12.2828 14.2876 12.9161 13.2434C13.5465 12.2038 14.4151 11.4838 15.3102 10.9942C16.9904 10.075 18.9742 9.85886 20.4419 9.78141C21.221 9.7403 21.9877 9.73505 22.6357 9.73061C22.8378 9.72923 23.0253 9.7279 23.2 9.726V7C23.2 5.34315 24.5431 4 26.2 4Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );