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="M10 9.77143H16V10.4667C15.3844 10.8043 15 11.4513 15 12.1558V19.8442C15 20.5487 15.3844 21.1957 16 21.5333V22.2285H10V21.5333C10.6156 21.1957 11 20.5487 11 19.8442V12.1558C11 11.4513 10.6156 10.8043 10 10.4667V9.77143ZM8 21.4891C8 20.7847 8.38438 20.1377 9 19.8001V12.1999C8.38438 11.8623 8 11.2153 8 10.5109V6H18.0571V9.77143H18V10.5109C18 11.2153 17.6156 11.8623 17 12.1999V19.8001C17.6156 20.1377 18 20.7847 18 21.4891V22.2285H18.0571V25.9999H8V21.4891Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 30H8L8 40H18V30ZM8 28C6.89543 28 6 28.8954 6 30V40C6 41.1046 6.89543 42 8 42H18C19.1046 42 20 41.1046 20 40V30C20 28.8954 19.1046 28 18 28H8Z" fill="black"/>
<path d="M9 36H11V39H9V36Z" fill="black"/>
<path d="M12 34H14V39H12V34Z" fill="black"/>
<path d="M15 31H17V39H15V31Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M37 8H28V10H37V8ZM26 12H27.5333V14.1949C27.5333 15.0557 27.1636 15.875 26.5182 16.4444L24.6919 18.0559C23.6162 19.005 23 20.3705 23 21.8051V37C23 39.7614 25.2386 42 28 42H37C39.7614 42 42 39.7614 42 37V21.8051C42 20.3705 41.3838 19.005 40.3081 18.0559L38.4818 16.4444C37.8364 15.875 37.4667 15.0557 37.4667 14.1949V12H39V8C39 6.89543 38.1046 6 37 6H28C26.8954 6 26 6.89543 26 8V12ZM35.4667 14.1949V12H29.5333V14.1949C29.5333 15.6295 28.9171 16.995 27.8414 17.9441L26.0151 19.5556C25.3697 20.125 25 20.9443 25 21.8051V37C25 38.6569 26.3431 40 28 40H37C38.6569 40 40 38.6569 40 37V21.8051C40 20.9443 39.6303 20.125 38.9849 19.5556L37.1586 17.9441C36.0829 16.995 35.4667 15.6295 35.4667 14.1949ZM33 21.5C33 21.2239 32.7761 21 32.5 21C32.2239 21 32 21.2239 32 21.5V24.2276C31.7195 24.492 31.4772 24.9726 31.3015 25.5944L30.5 24.7929V23.5C30.5 23.3674 30.4473 23.2402 30.3535 23.1464L28.8535 21.6464C28.6583 21.4512 28.3417 21.4512 28.1464 21.6464C27.9512 21.8417 27.9512 22.1583 28.1464 22.3536L29.5 23.7071V25C29.5 25.1326 29.5527 25.2598 29.6464 25.3536L31.0712 26.7783C31.0615 26.8597 31.0526 26.9422 31.0448 27.0258L26.0376 27.8571C25.8811 28.5714 26.1314 30 28.3841 30C29.9332 30 30.6834 29.0542 31.0009 28.1382C31.0055 28.5042 31.0286 28.8576 31.0677 29.1922L28.7133 30.8404C28.5231 30.9735 28.4495 31.2201 28.5358 31.4357L28.8527 32.228L27.8077 32.6635C27.5528 32.7697 27.4323 33.0624 27.5385 33.3173C27.6447 33.5722 27.9374 33.6927 28.1923 33.5865L29.6923 32.9615C29.9446 32.8564 30.0658 32.5681 29.9642 32.3143L29.6114 31.4323L31.2659 30.2742C31.3292 30.5183 31.4025 30.7427 31.4842 30.9432L31.0358 32.0643C31.0121 32.1234 31 32.1864 31 32.25V32.9496L29.6096 34.6877C29.4371 34.9033 29.472 35.2179 29.6877 35.3904C29.9033 35.5629 30.2179 35.528 30.3904 35.3123L31.8904 33.4373C31.9614 33.3487 32 33.2385 32 33.125V32.3463L32.1759 31.9064C32.2803 31.9677 32.3887 32 32.5 32C32.6303 32 32.7567 31.9557 32.8772 31.8725L33 32.118V33.125C33 33.2385 33.0386 33.3487 33.1096 33.4373L34.6096 35.3123C34.7821 35.528 35.0967 35.5629 35.3123 35.3904C35.528 35.2179 35.5629 34.9033 35.3904 34.6877L34 32.9496V32C34 31.9224 33.9819 31.8458 33.9472 31.7764L33.5224 30.9268C33.6014 30.7305 33.6725 30.5117 33.7341 30.2742L35.3886 31.4323L35.0358 32.3143C34.9342 32.5681 35.0554 32.8564 35.3077 32.9615L36.8077 33.5865C37.0626 33.6927 37.3553 33.5722 37.4615 33.3173C37.5677 33.0624 37.4472 32.7697 37.1923 32.6635L36.1473 32.228L36.4642 31.4357C36.5505 31.2201 36.4769 30.9735 36.2867 30.8404L33.9322 29.1922C33.9556 28.9922 33.9733 28.7854 33.9847 28.5732C34.3752 29.3309 35.1129 30 36.4159 30C38.6686 30 38.9189 28.5714 38.7624 27.8571L33.9583 27.0595C33.9497 26.9644 33.9398 26.8707 33.9287 26.7784L35.3535 25.3536C35.4473 25.2598 35.5 25.1326 35.5 25V23.7071L36.8535 22.3536C37.0488 22.1583 37.0488 21.8417 36.8535 21.6464C36.6583 21.4512 36.3417 21.4512 36.1464 21.6464L34.6464 23.1464C34.5527 23.2402 34.5 23.3674 34.5 23.5V24.7929L33.6985 25.5944C33.5227 24.9726 33.2805 24.492 33 24.2276V21.5ZM27.1801 28.6811C27.3152 28.8112 27.6338 29 28.3841 29C29.1571 29 29.5596 28.683 29.8083 28.3151C29.8257 28.2893 29.8425 28.263 29.8586 28.2364L27.1801 28.6811ZM37.6199 28.6811C37.4848 28.8112 37.1662 29 36.4159 29C35.6429 29 35.2404 28.683 34.9917 28.3151C34.9743 28.2893 34.9575 28.263 34.9414 28.2364L37.6199 28.6811ZM32.6243 30.4773C32.8438 29.892 33 29.0164 33 28C33 26.9836 32.8438 26.108 32.6243 25.5227C32.5818 25.4092 32.5397 25.3143 32.5 25.2358C32.4603 25.3143 32.4182 25.4092 32.3757 25.5227C32.1562 26.108 32 26.9836 32 28C32 29.0164 32.1562 29.892 32.3757 30.4773C32.4182 30.5908 32.4603 30.6857 32.5 30.7642C32.5397 30.6857 32.5818 30.5908 32.6243 30.4773Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );