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="M6.87868 6.87868C6.33579 7.42157 6 8.17157 6 9V14H8.1377C8.13775 14.0441 8.13924 14.0884 8.14222 14.133L9.87555 40.133C9.94559 41.1836 10.8182 42 11.8711 42H35.1289C36.1818 42 37.0544 41.1836 37.1245 40.133L38.8578 14.133C38.8608 14.0884 38.8623 14.0441 38.8623 14H42V9C42 8.1115 41.6137 7.31321 41 6.76389C40.9878 6.75302 40.9756 6.74224 40.9633 6.73156C40.7578 6.5536 40.528 6.40309 40.2794 6.28571C40.2426 6.26833 40.2054 6.25167 40.1677 6.23575C39.8088 6.08395 39.4142 6 39 6H9C8.54237 6 8.10866 6.10247 7.72059 6.28571C7.7135 6.28906 7.70643 6.29243 7.69938 6.29583C7.44407 6.41885 7.20886 6.57695 7 6.76389C6.9585 6.80103 6.91805 6.83931 6.87868 6.87868ZM36.8622 14H10.1378L10.4045 18H21C22.1046 18 23 18.8954 23 20V22H36.3289L36.8622 14ZM11.1142 20L11.892 34H21V20H11.1142ZM11 11.7143H9V8.28571H11V11.7143ZM15 8.28571H13V11.7143H15V8.28571ZM19 11.7143H17V8.28571H19V11.7143ZM23 8.28571H21V11.7143H23V8.28571ZM27 11.7143H25V8.28571H27V11.7143ZM31 8.28571H29V11.7143H31V8.28571ZM35 11.7143H33V8.28571H35V11.7143ZM39 8.28571H37V11.7143H39V8.28571Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);