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="M19.3012 6.56262C18.0055 6.80041 16.9179 7 16 7C15.4477 7 15 7.44772 15 8V18C15 22.9706 19.0294 27 24 27C28.9706 27 33 22.9706 33 18V8C33 7.44772 32.5523 7 32 7C31.1767 7 30.1624 6.81378 28.9151 6.58477L28.541 6.51624C27.1709 6.26622 25.6007 6 24 6C22.4527 6 20.9151 6.26718 19.5536 6.51634L19.3012 6.56262ZM19.6033 8.5407C18.7308 8.7014 17.8403 8.86543 17 8.94706V10.4523C17.6919 10.3834 18.4614 10.2578 19.316 10.1184L19.5731 10.0765C20.9353 9.85487 22.4639 9.61905 24 9.61905C25.5897 9.61905 27.1512 9.85411 28.5216 10.0764L28.8984 10.1378C29.6839 10.266 30.3821 10.38 31 10.4465V8.94208C30.2322 8.86174 29.4055 8.70922 28.5853 8.55789L28.5832 8.5575C28.4492 8.53278 28.3154 8.50809 28.182 8.48376C26.8121 8.23378 25.4011 8 24 8C22.6567 8 21.2843 8.23282 19.9136 8.48366L19.6033 8.5407ZM24 25C27.866 25 31 21.866 31 18V15.8369C30.2413 15.7658 29.4224 15.6315 28.6039 15.4973C28.4697 15.4753 28.3354 15.4533 28.2014 15.4315C26.8318 15.2094 25.4122 15 24 15C22.6454 15 21.2641 15.2086 19.8942 15.4315L19.586 15.4818C18.7145 15.6245 17.8313 15.769 17 15.8414V18C17 21.866 20.134 25 24 25ZM28.8984 13.5187C29.6839 13.6469 30.3821 13.7609 31 13.8274V12.4559C30.2413 12.3848 29.4224 12.2505 28.6039 12.1163L28.6029 12.1162C28.4692 12.0943 28.3348 12.0722 28.2014 12.0506C26.8318 11.8284 25.4122 11.619 24 11.619C22.6454 11.619 21.2641 11.8277 19.8942 12.0505L19.586 12.1009C18.7145 12.2435 17.8313 12.3881 17 12.4604V13.8333C17.6919 13.7643 18.4614 13.6388 19.316 13.4993L19.5731 13.4574C20.9353 13.2358 22.4639 13 24 13C25.5897 13 27.1512 13.2351 28.5216 13.4573L28.8984 13.5187Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M23.4706 29.0047C31.0755 28.8704 42 31.6421 42 36.0405V42H6V36.0405C6 31.6421 16.2579 29.132 23.4706 29.0047ZM39.9984 36C39.9819 35.7806 39.8227 35.3173 38.9574 34.6539C38.6695 34.4332 38.3327 34.2145 37.9506 34H10V33.98C9.60071 34.2053 9.25327 34.4355 8.96163 34.6678C8.17356 35.2956 8.01567 35.747 8.00117 36H39.9984ZM23.5059 31.0044C26.2546 30.9558 29.4816 31.3134 32.3936 32H15.5427C18.1606 31.3916 21.0221 31.0482 23.5059 31.0044ZM40 38V40H8V38H40Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);