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="M22.8353 10.0654C22.1878 9.84955 21.5191 10.3315 21.5191 11.0141V12.5819H15V35.3986H21.5191V37.2128C21.5191 37.8953 22.1878 38.3773 22.8353 38.1614L31.7004 35.2064C32.1087 35.0703 32.3842 34.6882 32.3842 34.2577V13.9691C32.3842 13.5387 32.1087 13.1565 31.7004 13.0204L22.8353 10.0654ZM25.8651 23.3891C25.8651 24.1892 25.5408 24.8378 25.1408 24.8378C24.7407 24.8378 24.4164 24.1892 24.4164 23.3891C24.4164 22.589 24.7407 21.9404 25.1408 21.9404C25.5408 21.9404 25.8651 22.589 25.8651 23.3891ZM21.5191 14.5819H17V33.3986H21.5191V14.5819Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M9 6C7.34315 6 6 7.34315 6 9V39C6 40.6569 7.34315 42 9 42H39C40.6569 42 42 40.6569 42 39V9C42 7.34315 40.6569 6 39 6H9ZM40 9C40 8.44771 39.5523 8 39 8H9C8.44771 8 8 8.44772 8 9V39C8 39.5523 8.44772 40 9 40H39C39.5523 40 40 39.5523 40 39V9Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );