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 14C6 9.58172 9.58172 6 14 6H34C38.4183 6 42 9.58172 42 14V34C42 38.4183 38.4183 42 34 42H14C9.58172 42 6 38.4183 6 34V14ZM29.9 16.1H18.1C16.9954 16.1 16.1 16.9954 16.1 18.1V29.9C16.1 31.0046 16.9954 31.9 18.1 31.9H29.9C31.0046 31.9 31.9 31.0046 31.9 29.9V18.1C31.9 16.9954 31.0046 16.1 29.9 16.1ZM18.1 14.1C15.8909 14.1 14.1 15.8909 14.1 18.1V29.9C14.1 32.1091 15.8909 33.9 18.1 33.9H29.9C32.1091 33.9 33.9 32.1091 33.9 29.9V18.1C33.9 15.8909 32.1091 14.1 29.9 14.1H18.1ZM20.4 19.5C20.8971 19.5 21.3 19.0971 21.3 18.6C21.3 18.1029 20.8971 17.7 20.4 17.7C19.9029 17.7 19.5 18.1029 19.5 18.6C19.5 19.0971 19.9029 19.5 20.4 19.5ZM23.1 21.3C23.1 21.7971 22.6971 22.2 22.2 22.2C21.7029 22.2 21.3 21.7971 21.3 21.3C21.3 20.8029 21.7029 20.4 22.2 20.4C22.6971 20.4 23.1 20.8029 23.1 21.3ZM18.6 22.2C19.0971 22.2 19.5 21.7971 19.5 21.3C19.5 20.8029 19.0971 20.4 18.6 20.4C18.1029 20.4 17.7 20.8029 17.7 21.3C17.7 21.7971 18.1029 22.2 18.6 22.2ZM21.3 24C21.3 24.4971 20.8971 24.9 20.4 24.9C19.9029 24.9 19.5 24.4971 19.5 24C19.5 23.5029 19.9029 23.1 20.4 23.1C20.8971 23.1 21.3 23.5029 21.3 24ZM22.2 27.6C22.6971 27.6 23.1 27.1971 23.1 26.7C23.1 26.2029 22.6971 25.8 22.2 25.8C21.7029 25.8 21.3 26.2029 21.3 26.7C21.3 27.1971 21.7029 27.6 22.2 27.6ZM19.5 26.7C19.5 27.1971 19.0971 27.6 18.6 27.6C18.1029 27.6 17.7 27.1971 17.7 26.7C17.7 26.2029 18.1029 25.8 18.6 25.8C19.0971 25.8 19.5 26.2029 19.5 26.7ZM20.4 30.3C20.8971 30.3 21.3 29.8971 21.3 29.4C21.3 28.9029 20.8971 28.5 20.4 28.5C19.9029 28.5 19.5 28.9029 19.5 29.4C19.5 29.8971 19.9029 30.3 20.4 30.3ZM24.9 18.6C24.9 19.0971 24.4971 19.5 24 19.5C23.5029 19.5 23.1 19.0971 23.1 18.6C23.1 18.1029 23.5029 17.7 24 17.7C24.4971 17.7 24.9 18.1029 24.9 18.6ZM25.8 22.2C26.2971 22.2 26.7 21.7971 26.7 21.3C26.7 20.8029 26.2971 20.4 25.8 20.4C25.3029 20.4 24.9 20.8029 24.9 21.3C24.9 21.7971 25.3029 22.2 25.8 22.2ZM24.9 24C24.9 24.4971 24.4971 24.9 24 24.9C23.5029 24.9 23.1 24.4971 23.1 24C23.1 23.5029 23.5029 23.1 24 23.1C24.4971 23.1 24.9 23.5029 24.9 24ZM25.8 27.6C26.2971 27.6 26.7 27.1971 26.7 26.7C26.7 26.2029 26.2971 25.8 25.8 25.8C25.3029 25.8 24.9 26.2029 24.9 26.7C24.9 27.1971 25.3029 27.6 25.8 27.6ZM24.9 29.4C24.9 29.8971 24.4971 30.3 24 30.3C23.5029 30.3 23.1 29.8971 23.1 29.4C23.1 28.9029 23.5029 28.5 24 28.5C24.4971 28.5 24.9 28.9029 24.9 29.4ZM27.6 19.5C28.0971 19.5 28.5 19.0971 28.5 18.6C28.5 18.1029 28.0971 17.7 27.6 17.7C27.1029 17.7 26.7 18.1029 26.7 18.6C26.7 19.0971 27.1029 19.5 27.6 19.5ZM30.3 21.3C30.3 21.7971 29.8971 22.2 29.4 22.2C28.9029 22.2 28.5 21.7971 28.5 21.3C28.5 20.8029 28.9029 20.4 29.4 20.4C29.8971 20.4 30.3 20.8029 30.3 21.3ZM27.6 24.9C28.0971 24.9 28.5 24.4971 28.5 24C28.5 23.5029 28.0971 23.1 27.6 23.1C27.1029 23.1 26.7 23.5029 26.7 24C26.7 24.4971 27.1029 24.9 27.6 24.9ZM30.3 26.7C30.3 27.1971 29.8971 27.6 29.4 27.6C28.9029 27.6 28.5 27.1971 28.5 26.7C28.5 26.2029 28.9029 25.8 29.4 25.8C29.8971 25.8 30.3 26.2029 30.3 26.7ZM27.6 30.3C28.0971 30.3 28.5 29.8971 28.5 29.4C28.5 28.9029 28.0971 28.5 27.6 28.5C27.1029 28.5 26.7 28.9029 26.7 29.4C26.7 29.8971 27.1029 30.3 27.6 30.3Z" fill="black"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);