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="24" height="24" viewBox="0 0 24 24" stroke-width="1.5" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.25 3.6C2.25 2.85442 2.85442 2.25 3.6 2.25H20.4C21.1456 2.25 21.75 2.85444 21.75 3.6V20.4C21.75 21.1456 21.1456 21.75 20.4 21.75H3.6C2.85444 21.75 2.25 21.1456 2.25 20.4V3.6ZM15.5793 7.52029C15.564 7.50344 15.5478 7.48728 15.531 7.47189C15.4667 7.41301 15.3946 7.36736 15.3183 7.33495C15.2282 7.29661 15.129 7.27539 15.0249 7.27539H15.0246H10.0752C9.66098 7.27539 9.3252 7.61118 9.3252 8.02539C9.3252 8.4396 9.66098 8.77539 10.0752 8.77539H13.2142L10.9591 11.0306C10.2475 11.7421 9.85804 12.4904 9.70986 13.2313C9.56278 13.9667 9.66365 14.6426 9.84979 15.201C10.0349 15.7563 10.3088 16.21 10.5311 16.5212C10.7276 16.7964 10.8911 16.9711 10.9435 17.0252C11.2326 17.32 11.7233 17.3374 12.0197 17.041C12.3124 16.7483 12.313 16.2742 12.0206 15.9813C11.9228 15.8778 11.8344 15.7652 11.7517 15.6494C11.5872 15.4192 11.3971 15.0995 11.2728 14.7267C11.1496 14.357 11.0958 13.9502 11.1807 13.5255C11.2646 13.1063 11.4938 12.6172 12.0197 12.0913L14.2749 9.83606V12.9752C14.2749 13.3894 14.6107 13.7252 15.0249 13.7252C15.4391 13.7252 15.7749 13.3894 15.7749 12.9752V8.02539C15.7749 7.91803 15.7523 7.81593 15.7117 7.72359C15.6797 7.65075 15.6356 7.58196 15.5793 7.52029Z" fill="currentColor"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);