build method
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:
- the fields of the widget, which themselves must not change over time, and
- any ambient state obtained from the
context
using BuildContext.dependOnInheritedWidgetOfExactType.
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="M20 18.6L17.75 24H22.25L20 18.6Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M38 15L28 4H14C11.7909 4 10 5.79086 10 8V40C10 42.2091 11.7909 44 14 44H34C36.2091 44 38 42.2091 38 40V15ZM20 15C20.4037 15 20.7678 15.2427 20.9231 15.6154L25.9231 27.6154C26.1355 28.1252 25.8944 28.7107 25.3846 28.9231C24.8748 29.1355 24.2893 28.8944 24.0769 28.3846L23.0833 26H16.9167L15.9231 28.3846C15.7107 28.8944 15.1252 29.1355 14.6154 28.9231C14.1056 28.7107 13.8645 28.1252 14.0769 27.6154L19.0769 15.6154C19.2322 15.2427 19.5963 15 20 15ZM15 32C14.4477 32 14 32.4477 14 33C14 33.5523 14.4477 34 15 34L33 34C33.5523 34 34 33.5523 34 33C34 32.4477 33.5523 32 33 32L15 32ZM14 37C14 36.4477 14.4477 36 15 36H27C27.5523 36 28 36.4477 28 37C28 37.5523 27.5523 38 27 38H15C14.4477 38 14 37.5523 14 37ZM31 22C31 21.4477 30.5523 21 30 21C29.4477 21 29 21.4477 29 22V24H27C26.4477 24 26 24.4477 26 25C26 25.5523 26.4477 26 27 26H29V28C29 28.5523 29.4477 29 30 29C30.5523 29 31 28.5523 31 28V26H33C33.5523 26 34 25.5523 34 25C34 24.4477 33.5523 24 33 24H31V22ZM28 7L35 15H29C28.4477 15 28 14.5523 28 14V7Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.9225 27.614L25.9231 27.6154C25.9516 27.6839 25.9719 27.7537 25.9846 27.8238C25.8888 27.7893 25.7953 27.7502 25.7043 27.7065C25.3551 27.5391 25.0433 27.306 24.7849 27.0232C24.7279 27.0359 24.6712 27.0537 24.6154 27.0769C24.106 27.2892 23.8649 27.8739 24.0765 28.3835L23.0833 26H16.9167L15.9234 28.3837C15.9233 28.384 15.9236 28.3834 15.9234 28.3837C15.711 28.8935 15.1252 29.1355 14.6154 28.9231C14.1056 28.7107 13.8645 28.1252 14.0769 27.6154C14.0768 27.6157 14.077 27.6151 14.0769 27.6154L15.0705 25.2308C15.0704 25.2309 15.0706 25.2306 15.0705 25.2308L19.0769 15.6154C19.2322 15.2427 19.5963 15 20 15C20.4037 15 20.7678 15.2427 20.9231 15.6154L21.8455 17.8293C21.8457 17.8298 21.8459 17.8303 21.8462 17.8308L24.0962 23.2308C24.0963 23.2312 24.0965 23.2316 24.0967 23.232L25.9225 27.614ZM25.8459 22.23L22.7692 14.8462C22.3034 13.7282 21.2111 13 20 13C18.7889 13 17.6966 13.7282 17.2308 14.8462L12.2308 26.8462C12.0829 27.201 12.0083 27.568 12 27.9305V8C12 6.89543 12.8954 6 14 6H26.2679C26.0961 6.29755 26 6.64066 26 7V14C26 15.6569 27.3431 17 29 17H35C35.3585 17 35.7018 16.9042 36 16.7321V25C36 23.3431 34.6569 22 33 22C33 20.3431 31.6569 19 30 19C28.3431 19 27 20.3431 27 22C26.591 22 26.2011 22.0818 25.8459 22.23ZM26.6153 24.0767C26.254 24.2274 26 24.584 26 25C26 25.5523 26.4477 26 27 26H29V28C29 28.5523 29.4477 29 30 29C30.5523 29 31 28.5523 31 28V26H33C33.5523 26 34 25.5523 34 25C34 24.4477 33.5523 24 33 24H31V22C31 21.4477 30.5523 21 30 21C29.4477 21 29 21.4477 29 22V24H27C26.8637 24 26.7337 24.0273 26.6153 24.0767ZM27.5 29.6589C27.5798 29.7789 27.6681 29.8929 27.7639 30H27.237C27.3331 29.8923 27.4209 29.7783 27.5 29.6589ZM22.2308 29.1538C22.3636 29.4726 22.545 29.7563 22.7628 30L22.2308 29.1538ZM22.7628 30H17.2372C17.455 29.7563 17.6364 29.4726 17.7692 29.1538L18.25 28H21.75L22.2308 29.1538M13.3409 30.5001C12.5134 29.9523 12.0222 29.0338 12 28.0671V32.9988C12.0004 31.9559 12.533 31.0374 13.3409 30.5001ZM12.7639 35C12.2891 34.4695 12.0003 33.7691 12 33.0012V36.9988C12.0003 36.2309 12.2891 35.5305 12.7639 35ZM32.2361 30C32.7111 29.4692 33 28.7684 33 28C34.6569 28 36 26.6569 36 25V33C36 31.3431 34.6569 30 33 30H32.2361ZM29.8293 36H33C34.6569 36 36 34.6569 36 33V40C36 41.1046 35.1046 42 34 42H14C12.8954 42 12 41.1046 12 40V37.0012C12.0007 38.6575 13.3435 40 15 40H27C28.6569 40 30 38.6569 30 37C30 36.6494 29.9398 36.3128 29.8293 36ZM27.0028 34H33C33.5523 34 34 33.5523 34 33C34 32.4477 33.5523 32 33 32L15 32C14.4477 32 14 32.4477 14 33C14 33.5523 14.4477 34 15 34H27C27.0009 34 27.0019 34 27.0028 34ZM38 15V40C38 42.2091 36.2091 44 34 44H14C11.7909 44 10 42.2091 10 40V8C10 5.79086 11.7909 4 14 4H28L38 15ZM28 7L35 15H29C28.4477 15 28 14.5523 28 14V7ZM22.25 24H17.75L20 18.6L22.25 24ZM24.0769 28.3846C24.0768 28.3842 24.0766 28.3839 24.0765 28.3835L24.0769 28.3846ZM15 36C14.4477 36 14 36.4477 14 37C14 37.5523 14.4477 38 15 38H27C27.5523 38 28 37.5523 28 37C28 36.4477 27.5523 36 27 36H15Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);