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="M23.1006 6.84867C23.4655 6.09862 24.5342 6.09862 24.8991 6.84867L41.3006 40.5628C41.6237 41.227 41.14 42.0002 40.4013 42.0002H7.59842C6.85978 42.0002 6.37606 41.227 6.69918 40.5628L23.1006 6.84867ZM27.6912 21.9815C28.721 22.6664 29.4976 23.7754 29.4976 25.2611C29.4976 26.8398 28.8608 27.9998 27.8297 28.7103C27.4024 29.0048 26.9426 29.1971 26.4999 29.3236L26.4999 30.5C26.4999 31.3284 25.8283 32 24.9999 32C24.1714 32 23.4999 31.3284 23.4999 30.5L23.4999 28.0586C23.4999 27.269 24.112 26.6147 24.8998 26.562C25.4538 26.5249 25.8741 26.4146 26.1275 26.24C26.2341 26.1666 26.3106 26.0823 26.368 25.9677C26.4277 25.8486 26.4976 25.6339 26.4976 25.2611C26.4976 24.9485 26.3746 24.7088 26.0298 24.4794C25.6377 24.2186 25.0077 24.0265 24.2512 24.0025C23.5027 23.9787 22.7759 24.125 22.2417 24.384C21.7048 24.6443 21.5086 24.9358 21.4532 25.1513C21.2471 25.9537 20.4296 26.4371 19.6272 26.231C18.8248 26.0249 18.3414 25.2074 18.5475 24.405C18.892 23.0637 19.8954 22.1875 20.9329 21.6845C21.9732 21.1802 23.1958 20.9674 24.3465 21.004C25.4894 21.0403 26.7088 21.328 27.6912 21.9815ZM24.9999 38C26.1044 38 26.9999 37.1046 26.9999 36C26.9999 34.8954 26.1044 34 24.9999 34C23.8953 34 22.9999 34.8954 22.9999 36C22.9999 37.1046 23.8953 38 24.9999 38Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );