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="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.75 12.641V15.9121C3.75 16.9739 4.36131 17.9409 5.32052 18.3963L10.3205 20.7703C11.0669 21.1246 11.9331 21.1246 12.6795 20.7703L17.6795 18.3963C18.6387 17.9409 19.25 16.9739 19.25 15.9121V12.6411L12.7746 15.8788C11.9723 16.2799 11.0279 16.2799 10.2255 15.8788L3.75 12.641Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.8963 3.46381C11.2764 3.27378 11.7237 3.27378 12.1038 3.46381L20.7622 7.79299C21.7572 8.2905 21.7572 9.71044 20.7622 10.2079L12.1038 14.5371C11.7237 14.7272 11.2764 14.7272 10.8963 14.5371L2.23796 10.2079C1.24295 9.71044 1.24294 8.2905 2.23796 7.79299L10.8963 3.46381Z" fill="currentColor"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19.8292 8.16475C20.0145 7.79427 20.465 7.6441 20.8355 7.82934L22.8355 8.82934C23.0895 8.95639 23.25 9.21609 23.25 9.50016L23.25 13.0002C23.25 13.4144 22.9143 13.7502 22.5 13.7502C22.0858 13.7502 21.75 13.4144 21.75 13.0002L21.75 9.96369L20.1646 9.17098C19.7941 8.98574 19.644 8.53524 19.8292 8.16475Z" fill="currentColor"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );