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="M19.9999 13.0015L6.73461 36.0012H33.2652L30.0617 30.4469C30.9326 30.9006 31.8877 31.215 32.8974 31.3605L35.8626 36.5016C36.2471 37.1683 35.766 38.0012 34.9964 38.0012H5.00344C4.23384 38.0012 3.75269 37.1683 4.1372 36.5016L19.1337 10.5004C19.5185 9.83321 20.4813 9.83321 20.8661 10.5004L25.8855 19.2031C25.5223 20.1112 25.3039 21.0927 25.2587 22.1193L19.9999 13.0015Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M31.482 28.9065C32.3122 29.258 33.225 29.4524 34.1832 29.4524C35.8495 29.4524 37.3785 28.8646 38.5741 27.885L42.4957 31.8065L44.0042 30.298L39.9999 26.2938C40.7062 25.2076 41.1165 23.9112 41.1165 22.519C41.1165 18.6899 38.0124 15.5857 34.1832 15.5857C30.6449 15.5857 27.7257 18.2361 27.3026 21.66C27.2678 21.9415 27.2499 22.2282 27.2499 22.5191C27.2499 23.4807 27.4457 24.3966 27.7995 25.2291C28.5021 26.8821 29.8279 28.2061 31.482 28.9065ZM29.3832 22.519C29.3832 25.17 31.5322 27.319 34.1832 27.319C36.8342 27.319 38.9832 25.17 38.9832 22.519C38.9832 19.8681 36.8342 17.719 34.1832 17.719C31.5322 17.719 29.3832 19.8681 29.3832 22.519Z" fill="black"/>
<path d="M18.7491 30.05H21.2505V32.55H18.7491V30.05Z" fill="black"/>
<path d="M19.9999 20.0447C19.3092 20.0447 18.7492 20.6046 18.7492 21.2954V26.7948C18.7492 27.4855 19.3092 28.0454 19.9999 28.0454C20.6906 28.0454 21.2506 27.4855 21.2506 26.7948V21.2954C21.2506 20.6046 20.6906 20.0447 19.9999 20.0447Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);