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="M7 42C6.44772 42 6 41.5523 6 41V6H8V35H11.0523C17.6037 35 23.406 33.6319 27.8954 30.4676C32.0479 27.5408 35.1717 23.0109 36.6981 16.3624L34.5655 17.8247C34.11 18.1371 33.4876 18.021 33.1753 17.5655C32.8629 17.11 32.979 16.4876 33.4345 16.1753L37.8095 13.1753C38.0451 13.0137 38.3385 12.9606 38.6157 13.0294C38.893 13.0982 39.1276 13.2822 39.2604 13.5352L41.8854 18.5352C42.1421 19.0242 41.9538 19.6287 41.4648 19.8854C40.9758 20.1421 40.3713 19.9538 40.1146 19.4648L38.6696 16.7124C37.057 23.8232 33.6809 28.8367 29.0476 32.1024C24.1117 35.5814 17.8585 37 11.0523 37H8V40H42V42H7Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.4816 16.5C14.6364 17.439 15.0058 18.3058 15.5376 19.0482L14.55 20.0358L14.4071 19.8929C14.0166 19.5024 13.3834 19.5024 12.9929 19.8929C12.6024 20.2834 12.6024 20.9166 12.9929 21.3071L14.6929 23.0071C15.0834 23.3976 15.7166 23.3976 16.1071 23.0071C16.4976 22.6166 16.4976 21.9834 16.1071 21.5929L15.9642 21.45L16.9518 20.4624C17.6942 20.9942 18.561 21.3636 19.5 21.5184V23.0112C19.0189 23.0835 18.65 23.4987 18.65 24C18.65 24.5523 19.0977 25 19.65 25H21.35C21.9023 25 22.35 24.5523 22.35 24C22.35 23.4987 21.9811 23.0835 21.5 23.0112V21.5184C22.6467 21.3293 23.6857 20.8204 24.5221 20.0863L25.8858 21.45L25.7429 21.5929C25.3524 21.9834 25.3524 22.6166 25.7429 23.0071C26.1334 23.3976 26.7666 23.3976 27.1571 23.0071L28.8571 21.3071C29.2476 20.9166 29.2476 20.2834 28.8571 19.8929C28.4666 19.5024 27.8334 19.5024 27.4429 19.8929L27.3 20.0358L25.795 18.5308C26.149 17.9136 26.3983 17.2285 26.5184 16.5H28.0112C28.0835 16.9811 28.4987 17.35 29 17.35C29.5523 17.35 30 16.9023 30 16.35V14.65C30 14.0977 29.5523 13.65 29 13.65C28.4987 13.65 28.0835 14.0189 28.0112 14.5H26.5184C26.3636 13.561 25.9942 12.6942 25.4624 11.9518L26.45 10.9642L26.5929 11.1071C26.9834 11.4976 27.6166 11.4976 28.0071 11.1071C28.3976 10.7166 28.3976 10.0834 28.0071 9.69289L26.3071 7.99289C25.9166 7.60237 25.2834 7.60237 24.8929 7.99289C24.5024 8.38342 24.5024 9.01658 24.8929 9.40711L25.0358 9.55L24.0482 10.5376C23.3058 10.0058 22.439 9.63643 21.5 9.48157V7.98882C21.9811 7.91645 22.35 7.5013 22.35 7C22.35 6.44772 21.9023 6 21.35 6H19.65C19.0977 6 18.65 6.44772 18.65 7C18.65 7.5013 19.0189 7.91645 19.5 7.98883V9.48157C18.561 9.63643 17.6942 10.0058 16.9518 10.5376L15.9642 9.55L16.1071 9.40711C16.4976 9.01658 16.4976 8.38342 16.1071 7.99289C15.7166 7.60237 15.0834 7.60237 14.6929 7.99289L12.9929 9.69289C12.6024 10.0834 12.6024 10.7166 12.9929 11.1071C13.3834 11.4976 14.0166 11.4976 14.4071 11.1071L14.55 10.9642L15.5376 11.9518C15.0058 12.6942 14.6364 13.561 14.4816 14.5H12.9888C12.9165 14.0189 12.5013 13.65 12 13.65C11.4477 13.65 11 14.0977 11 14.65V16.35C11 16.9023 11.4477 17.35 12 17.35C12.5013 17.35 12.9165 16.9811 12.9888 16.5H14.4816ZM16.4 15.5C16.4 13.2356 18.2356 11.4 20.5 11.4C22.7644 11.4 24.6 13.2356 24.6 15.5C24.6 17.7644 22.7644 19.6 20.5 19.6C18.2356 19.6 16.4 17.7644 16.4 15.5Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );