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="M6 41C6 41.5523 6.44772 42 7 42H41V40H8V39.362L17.3313 28.1645L28.6838 31.9487C29.0743 32.0788 29.5047 31.9564 29.7682 31.6402L39.7682 19.6402L38.2318 18.3598L28.6687 29.8355L17.3162 26.0513C16.9257 25.9211 16.4953 26.0436 16.2318 26.3598L8 36.2379V29.3866L17.2887 19.169L27.6583 22.9398C28.0544 23.0838 28.4984 22.964 28.7682 22.6402L38.7682 10.6402L37.2318 9.35982L27.6815 20.8201L17.3417 17.0602C16.9604 16.9215 16.533 17.0271 16.2601 17.3273L8 26.4134V7H6V41Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );