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="M18.8571 6C18.1878 6 17.5458 6.2659 17.0725 6.73921C16.5992 7.21251 16.3333 7.85445 16.3333 8.52381V11.3333H13.5238C12.8545 11.3333 12.2125 11.5992 11.7392 12.0725C11.2659 12.5458 11 13.1878 11 13.8571V16.1429C11 16.8122 11.2659 17.4542 11.7392 17.9275C12.2125 18.4008 12.8545 18.6667 13.5238 18.6667H16.3333V21.4762C16.3333 22.1455 16.5992 22.7875 17.0725 23.2608C17.5458 23.7341 18.1878 24 18.8571 24H21.1429C21.8122 24 22.4542 23.7341 22.9275 23.2608C23.4008 22.7875 23.6667 22.1455 23.6667 21.4762V18.6667H26.4762C27.1455 18.6667 27.7875 18.4008 28.2608 17.9275C28.7341 17.4542 29 16.8122 29 16.1429V13.8571C29 13.1878 28.7341 12.5458 28.2608 12.0725C27.7875 11.5992 27.1455 11.3333 26.4762 11.3333H23.6667V8.52381C23.6667 7.85445 23.4008 7.21251 22.9275 6.73921C22.4542 6.2659 21.8122 6 21.1429 6H18.8571ZM18.4868 8.15342C18.585 8.05519 18.7182 8 18.8571 8H21.1429C21.2818 8 21.415 8.05519 21.5132 8.15342C21.6115 8.25165 21.6667 8.38489 21.6667 8.52381V12.3333C21.6667 12.8856 22.1144 13.3333 22.6667 13.3333H26.4762C26.6151 13.3333 26.7483 13.3885 26.8466 13.4868C26.9448 13.585 27 13.7182 27 13.8571V16.1429C27 16.2818 26.9448 16.415 26.8466 16.5132C26.7483 16.6115 26.6151 16.6667 26.4762 16.6667H22.6667C22.1144 16.6667 21.6667 17.1144 21.6667 17.6667V21.4762C21.6667 21.6151 21.6115 21.7483 21.5132 21.8466C21.415 21.9448 21.2818 22 21.1429 22H18.8571C18.7182 22 18.585 21.9448 18.4868 21.8466C18.3885 21.7483 18.3333 21.6151 18.3333 21.4762V17.6667C18.3333 17.1144 17.8856 16.6667 17.3333 16.6667H13.5238C13.3849 16.6667 13.2517 16.6115 13.1534 16.5132C13.0552 16.415 13 16.2818 13 16.1429V13.8571C13 13.7182 13.0552 13.585 13.1534 13.4868C13.2517 13.3885 13.3849 13.3333 13.5238 13.3333H17.3333C17.8856 13.3333 18.3333 12.8856 18.3333 12.3333V8.52381C18.3333 8.38489 18.3885 8.25165 18.4868 8.15342Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );