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="M25.8692 14C28.1915 14 30 15.8313 30 18C30 20.1687 28.1915 22 25.8692 22H21.782C20.6774 22 19.782 22.8954 19.782 24C19.782 25.1046 20.6774 26 21.782 26H25.8692C28.1915 26 30 27.8313 30 30C30 32.1687 28.1915 34 25.8692 34H21.782C19.9595 34 18.438 32.8626 17.8811 31.3206C17.5059 30.2817 16.3595 29.7437 15.3206 30.1189C14.2817 30.4941 13.7437 31.6405 14.1189 32.6794C15.2453 35.7982 18.2656 38 21.782 38H25.8692C30.3188 38 34 34.4587 34 30C34 27.5963 32.9302 25.4593 31.2469 24C32.9302 22.5407 34 20.4037 34 18C34 13.5413 30.3188 10 25.8692 10H21.782C18.2656 10 15.2453 12.2018 14.1189 15.3206C13.7437 16.3595 14.2817 17.5059 15.3206 17.8811C16.3595 18.2563 17.5059 17.7183 17.8811 16.6794C18.438 15.1374 19.9595 14 21.782 14H25.8692Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );