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="M27.8954 30.4676C23.406 33.6319 17.6037 35 11.0523 35H8V6H6V41C6 41.5523 6.44772 42 7 42H42V40H8V37H11.0523C17.8585 37 24.1117 35.5814 29.0476 32.1024C33.6809 28.8367 37.057 23.8232 38.6696 16.7124L40.1146 19.4648C40.3713 19.9538 40.9758 20.1421 41.4648 19.8854C41.9538 19.6287 42.1421 19.0242 41.8854 18.5352L39.2604 13.5352C39.1276 13.2822 38.893 13.0982 38.6157 13.0294C38.3385 12.9606 38.0451 13.0137 37.8095 13.1753L33.4345 16.1753C32.979 16.4876 32.8629 17.11 33.1753 17.5655C33.4876 18.021 34.11 18.1371 34.5655 17.8247L36.6981 16.3624C35.1717 23.0109 32.0479 27.5408 27.8954 30.4676Z" fill="black"/>
<path d="M27 13.8571C27 13.453 26.8395 13.0654 26.5537 12.7796C26.2679 12.4939 25.8803 12.3333 25.4762 12.3333H21.6667V8.52381C21.6667 8.11967 21.5061 7.73208 21.2204 7.44631C20.9346 7.16054 20.547 7 20.1429 7H17.8571C17.453 7 17.0654 7.16054 16.7796 7.44631C16.4939 7.73208 16.3333 8.11967 16.3333 8.52381V12.3333H12.5238C12.1197 12.3333 11.7321 12.4939 11.4463 12.7796C11.1605 13.0654 11 13.453 11 13.8571V16.1429C11 16.547 11.1605 16.9346 11.4463 17.2204C11.7321 17.5061 12.1197 17.6667 12.5238 17.6667H16.3333V21.4762C16.3333 21.8803 16.4939 22.2679 16.7796 22.5537C17.0654 22.8395 17.453 23 17.8571 23H20.1429C20.547 23 20.9346 22.8395 21.2204 22.5537C21.5061 22.2679 21.6667 21.8803 21.6667 21.4762V17.6667H25.4762C25.8803 17.6667 26.2679 17.5061 26.5537 17.2204C26.8395 16.9346 27 16.547 27 16.1429V13.8571Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);