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 38C20 39.1046 19.1046 40 18 40C16.8954 40 16 39.1046 16 38C16 36.8954 16.8954 36 18 36C19.1046 36 20 36.8954 20 38Z" fill="black"/>
<path d="M18 31C17.1716 31 16.5 31.6716 16.5 32.5C16.5 33.3284 17.1716 34 18 34C18.8284 34 19.5 33.3284 19.5 32.5C19.5 31.6716 18.8284 31 18 31Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 8C15.7909 8 14 9.79086 14 12V25C14 27.2091 15.7909 29 18 29C20.2091 29 22 27.2091 22 25V12C22 9.79086 20.2091 8 18 8ZM20 25V12C20 10.8954 19.1046 10 18 10C16.8954 10 16 10.8954 16 12V25C16 26.1046 16.8954 27 18 27C19.1046 27 20 26.1046 20 25Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 4C10.8954 4 10 4.89543 10 6V42C10 43.1046 10.8954 44 12 44H24C25.1046 44 26 43.1046 26 42V6C26 4.89543 25.1046 4 24 4H12ZM24 6H12V42H24V6Z" fill="black"/>
<path d="M30.8507 8.10497C31.0882 8.00001 31.3453 7.97376 31.5927 8.02626C31.8406 8.07888 32.0778 8.21066 32.2704 8.41609C32.6481 8.81905 33.2809 8.83954 33.6838 8.46186C34.0868 8.08418 34.1073 7.45135 33.7296 7.04839C33.2668 6.55455 32.669 6.21013 32.0079 6.06983C31.3462 5.92939 30.6611 6.00217 30.0422 6.27565C29.4244 6.54871 28.9068 7.00632 28.5474 7.58032C28.1883 8.15375 28 8.82165 28 9.5C28 10.1784 28.1883 10.8463 28.5474 11.4197C28.9068 11.9937 29.4244 12.4513 30.0422 12.7244C30.6611 12.9978 31.3462 13.0706 32.0079 12.9302C32.669 12.7899 33.2668 12.4455 33.7296 11.9516C34.1073 11.5487 34.0868 10.9158 33.6838 10.5381C33.2809 10.1605 32.6481 10.181 32.2704 10.5839C32.0778 10.7893 31.8406 10.9211 31.5927 10.9738C31.3453 11.0262 31.0882 11 30.8507 10.895C30.6123 10.7897 30.3979 10.6064 30.2424 10.3582C30.0866 10.1094 30 9.81056 30 9.5C30 9.18945 30.0866 8.89065 30.2424 8.64184C30.3979 8.39359 30.6123 8.21034 30.8507 8.10497Z" fill="black"/>
<path d="M28.5 15C28.5 14.4477 28.9477 14 29.5 14H33.5C34.0523 14 34.5 14.4477 34.5 15C34.5 15.5523 34.0523 16 33.5 16H32.5V20C32.5 20.5523 32.0523 21 31.5 21C30.9477 21 30.5 20.5523 30.5 20V16H29.5C28.9477 16 28.5 15.5523 28.5 15Z" fill="black"/>
<path d="M30 27.5C30 27.2239 30.2239 27 30.5 27H31.5C31.7161 27 31.9027 27.1377 31.9718 27.3332C32.1559 27.854 32.7272 28.1269 33.2479 27.9428C33.7686 27.7588 34.0415 27.1875 33.8575 26.6668C33.5148 25.6971 32.5901 25 31.5 25H30.5C29.1193 25 28 26.1193 28 27.5C28 28.8807 29.1193 30 30.5 30H31.5C31.7761 30 32 30.2239 32 30.5C32 30.7761 31.7761 31 31.5 31H30.5C30.2839 31 30.0973 30.8623 30.0282 30.6668C29.8441 30.146 29.2728 29.8731 28.7521 30.0572C28.2314 30.2412 27.9585 30.8125 28.1425 31.3332C28.4852 32.3029 29.4099 33 30.5 33H31.5C32.8807 33 34 31.8807 34 30.5C34 29.1193 32.8807 28 31.5 28H30.5C30.2239 28 30 27.7761 30 27.5Z" fill="black"/>
<path d="M30.5 36C30.2239 36 30 36.2239 30 36.5C30 36.7761 30.2239 37 30.5 37H31.5C32.8807 37 34 38.1193 34 39.5C34 40.8807 32.8807 42 31.5 42H30.5C29.4099 42 28.4852 41.3029 28.1425 40.3332C27.9585 39.8125 28.2314 39.2412 28.7521 39.0572C29.2728 38.8731 29.8441 39.146 30.0282 39.6668C30.0973 39.8623 30.2839 40 30.5 40H31.5C31.7761 40 32 39.7761 32 39.5C32 39.2239 31.7761 39 31.5 39H30.5C29.1193 39 28 37.8807 28 36.5C28 35.1193 29.1193 34 30.5 34H31.5C32.5901 34 33.5148 34.6971 33.8575 35.6668C34.0415 36.1875 33.7686 36.7588 33.2479 36.9428C32.7272 37.1269 32.1559 36.854 31.9718 36.3332C31.9027 36.1377 31.7161 36 31.5 36H30.5Z" fill="black"/>
<path d="M38 26.5C38 26.0919 37.7519 25.7246 37.3732 25.5723C36.9946 25.42 36.5613 25.513 36.2786 25.8075L35.2786 26.8492C34.8961 27.2476 34.9091 27.8806 35.3075 28.2631C35.5014 28.4492 35.7509 28.5417 36 28.5417V31.5C36 32.0523 36.4477 32.5 37 32.5C37.5523 32.5 38 32.0523 38 31.5V26.5Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);