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 fill-rule="evenodd" clip-rule="evenodd" d="M41 8H28V12.3542C27.3776 13.0593 27 13.9856 27 15V24.9032L15.3225 24.9032C15.2456 24.9032 15.1692 24.9054 15.0933 24.9097L11.6006 23.0994C11.0296 22.8035 10.3277 22.9773 9.96086 23.5056C9.59445 24.0333 9.6761 24.7508 10.1517 25.1826L11.9243 26.7922C11.8786 26.8656 11.8352 26.9406 11.7942 27.0172L6.99655 27.417C6.43327 27.4639 6 27.9348 6 28.5C6 29.0652 6.43327 29.5361 6.99655 29.583L11.3225 29.9435V30.0565L6.99655 30.417C6.43327 30.4639 6 30.9348 6 31.5C6 32.0652 6.43327 32.5361 6.99655 32.583L11.3225 32.9435V33.0677L7.99504 33.4005C7.43017 33.457 7 33.9323 7 34.5C7 35.0677 7.43017 35.543 7.99504 35.5995L11.3225 35.9323V36C11.3225 36.0375 11.323 36.0749 11.3241 36.1122L8.98503 36.3851C8.42347 36.4506 8 36.9263 8 37.4917C8 38.0641 8.43373 38.5434 9.00328 38.6003L12.636 38.9636C13.346 39.6076 14.2884 40 15.3225 40L37.9999 40C40.2091 40 41.9999 38.2091 41.9999 36V33.0243L42 33V15C42 13.9856 41.6224 13.0593 41 12.3542V8ZM29 15C29 13.8954 29.8954 13 31 13H38C38.6244 13 39.182 13.2862 39.5488 13.7345L29 16.7915V15ZM29 18.8738V20.6771L40 24.3437V15.686L29 18.8738ZM39.9418 26.4325C39.9611 26.439 39.9805 26.4448 40 26.45V33L39.9999 33.0243V36C39.9999 36.1791 39.9764 36.3528 39.9322 36.518L29 25.5859V22.7853L39.9418 26.4325ZM27.4889 26.9032H23.9324L30.3651 37.9984L30.366 38L37.9999 38C38.1791 38 38.3528 37.9764 38.518 37.9322L27.4889 26.9032ZM28.0542 38L21.6206 26.9032H16.9324L23.366 38H28.0542ZM13.3225 28.9032C13.3225 28.0229 13.8913 27.2754 14.6814 27.0082L21.0542 38H15.3225C14.2179 38 13.3225 37.1046 13.3225 36V28.9032Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);