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" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10 11.2961V20C10 20.5523 10 21 11 21H13C14 21 14 20.5523 14 20V13.2382C12.4134 13.1382 10.9977 12.4085 10 11.2961Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.3982 9.20125C11.0407 10.5979 12.3972 11.5981 14 11.7341C14.1236 11.7446 14.2487 11.7499 14.375 11.7499C15.2208 11.7499 16.0106 11.5099 16.6799 11.0943L19.2927 13.7072L20.7069 12.293L18.0941 9.6801C18.5099 9.01074 18.7499 8.2209 18.7499 7.37497C18.7499 4.95874 16.7912 3 14.375 3C11.9587 3 10 4.95874 10 7.37497C10 8.02686 10.1426 8.64545 10.3982 9.20125ZM14.375 9.74995C14.2328 9.74995 14.0936 9.73746 13.9584 9.71353C13.4436 9.62244 12.9861 9.36555 12.643 9C12.2442 8.57517 12 8.00359 12 7.37497C12 6.06331 13.0633 5 14.375 5C15.6866 5 16.7499 6.06331 16.7499 7.37497C16.7499 8.68664 15.6866 9.74995 14.375 9.74995Z" fill="black"/>
<path d="M4 4C4 3.44772 4 3 5 3H7C8 3 8 3.44772 8 4V20C8 20.5523 8 21 7 21H5C4 21 4 20.5523 4 20V4Z" fill="black"/>
<path d="M17 15C16 15 16 15.4477 16 16V20C16 20.5523 16 21 17 21H19C19.5523 21 20 21 20 20V16C20 15.4477 20 15 19 15H17Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );