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="M30 36.5C30 37.3284 29.3284 38 28.5 38C27.6716 38 27 37.3284 27 36.5C27 35.6716 27.6716 35 28.5 35C29.3284 35 30 35.6716 30 36.5Z" fill="black"/>
<path d="M33.5 37C34.3284 37 35 36.3284 35 35.5C35 34.6716 34.3284 34 33.5 34C32.6716 34 32 34.6716 32 35.5C32 36.3284 32.6716 37 33.5 37Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 6C31.7209 6 38.0794 7.75002 38.9085 10H39V38C39 40.2091 32.2843 42 24 42C15.7157 42 9 40.2091 9 38V10H9.09155C9.92062 7.75002 16.2791 6 24 6ZM24 33C18.4431 33 13.5919 32.0935 11 30.7465V37.693C11.0549 37.7373 11.1341 37.795 11.2454 37.8652C11.7621 38.1909 12.6427 38.5583 13.9087 38.896C16.4116 39.5634 19.9802 40 24 40C28.0198 40 31.5884 39.5634 34.0913 38.896C35.3573 38.5583 36.2379 38.1909 36.7546 37.8652C36.8659 37.795 36.9451 37.7373 37 37.693V30.7465C34.4081 32.0935 29.5569 33 24 33ZM24 24C29.5569 24 34.4081 23.0935 37 21.7465V28.5H36.8233C36.779 28.536 36.7264 28.5761 36.6642 28.6203C36.1536 28.9824 35.2851 29.3904 34.0319 29.7663C31.5509 30.5106 28.0036 31 24 31C19.9964 31 16.4491 30.5106 13.9681 29.7663C12.7149 29.3904 11.8464 28.9824 11.3358 28.6203C11.2736 28.5761 11.221 28.536 11.1767 28.5H11V21.7465C13.5919 23.0935 18.4431 24 24 24ZM24 15C29.5569 15 34.4081 14.0935 37 12.7465V19.5H36.8233C36.779 19.536 36.7264 19.5761 36.6642 19.6203C36.1536 19.9824 35.2851 20.3904 34.0319 20.7663C31.5509 21.5106 28.0036 22 24 22C19.9964 22 16.4491 21.5106 13.9681 20.7663C12.7149 20.3904 11.8464 19.9824 11.3358 19.6203C11.2736 19.5761 11.221 19.536 11.1767 19.5H11V12.7465C13.5919 14.0935 18.4431 15 24 15ZM36.7503 10.4428C36.7767 10.4629 36.8009 10.4821 36.823 10.5002C36.7788 10.5362 36.7263 10.5762 36.6642 10.6203C36.1536 10.9824 35.2851 11.3904 34.0319 11.7663C31.5509 12.5106 28.0036 13 24 13C19.9964 13 16.4491 12.5106 13.9681 11.7663C12.7149 11.3904 11.8464 10.9824 11.3358 10.6203C11.2737 10.5762 11.2212 10.5362 11.177 10.5002C11.1991 10.4821 11.2233 10.4629 11.2499 10.4427C11.2762 10.4227 11.3048 10.4017 11.3358 10.3797C11.3929 10.3393 11.4544 10.2982 11.5204 10.2567C11.5705 10.2253 11.625 10.1925 11.684 10.1584C11.833 10.0725 11.9989 9.98603 12.1816 9.89971C12.5489 9.7262 12.9905 9.55011 13.5087 9.37846C13.8098 9.27875 14.1347 9.18119 14.4833 9.08694C15.2494 8.87981 16.1021 8.696 17.0262 8.54115C19.0592 8.20047 21.4378 8 24 8C27.7269 8 31.0653 8.42415 33.5167 9.08694C33.6946 9.13504 33.8663 9.184 34.0319 9.23367C35.0119 9.5277 35.775 9.84653 36.316 10.1584C36.3749 10.1924 36.4292 10.2251 36.4792 10.2565C36.5454 10.2981 36.607 10.3392 36.6642 10.3797C36.6952 10.4017 36.7239 10.4228 36.7503 10.4428ZM37.1107 37.5868C37.1107 37.5868 37.1069 37.5942 37.0938 37.6083C37.1033 37.5938 37.1107 37.5868 37.1107 37.5868ZM10.8893 37.5868C10.8893 37.5868 10.8967 37.5938 10.9062 37.6083C10.8931 37.5942 10.8893 37.5868 10.8893 37.5868Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);