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" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.6 2.25C2.85442 2.25 2.25 2.85441 2.25 3.6V20.4C2.25 21.1456 2.85441 21.75 3.6 21.75H20.4C21.1456 21.75 21.75 21.1456 21.75 20.4V3.6C21.75 2.85442 21.1456 2.25 20.4 2.25H3.6ZM9.6 6.25C8.85442 6.25 8.25 6.85442 8.25 7.6V12V16.9C8.25 17.6456 8.85442 18.25 9.6 18.25H12V17.5C12 18.25 12.0003 18.25 12.0007 18.25L12.0015 18.25L12.0033 18.25L12.0076 18.25L12.0197 18.2498C12.0292 18.2497 12.0415 18.2494 12.0566 18.249C12.0867 18.2481 12.1276 18.2463 12.1779 18.243C12.2782 18.2365 12.4171 18.2236 12.582 18.1984C12.9081 18.1486 13.3553 18.0476 13.8125 17.838C14.271 17.6279 14.7617 17.2981 15.1378 16.781C15.5197 16.2558 15.75 15.5829 15.75 14.75C15.75 13.9171 15.5197 13.2442 15.1378 12.719C14.8828 12.3684 14.5751 12.1039 14.2605 11.9044C14.4307 11.753 14.5919 11.5736 14.7334 11.3613C15.0588 10.8733 15.25 10.2562 15.25 9.5C15.25 8.74377 15.0588 8.12673 14.7334 7.63867C14.4112 7.15531 13.9869 6.84242 13.5854 6.64169C12.8037 6.25082 12.0383 6.25 12 6.25H9.6ZM9.75 12.75H11.9974L11.9975 12.75L12.0108 12.7503C12.0246 12.7507 12.0482 12.7517 12.0799 12.7538C12.1436 12.7579 12.2391 12.7666 12.3555 12.7844C12.5919 12.8205 12.8947 12.8913 13.1875 13.0255C13.479 13.1591 13.7383 13.3449 13.9247 13.6013C14.1053 13.8496 14.25 14.2079 14.25 14.75C14.25 15.2921 14.1053 15.6504 13.9247 15.8987C13.7383 16.1551 13.479 16.3409 13.1875 16.4745C12.8947 16.6087 12.5919 16.6795 12.3555 16.7156C12.2391 16.7334 12.1436 16.7421 12.0799 16.7462C12.0482 16.7483 12.0246 16.7493 12.0108 16.7497L11.9975 16.75L11.9973 16.75L9.75 16.75V12.75ZM11.9973 16.75L11.9967 16.75L11.9978 16.75L11.9988 16.75H11.9973ZM11.9959 11.25H9.75V7.75H11.999L11.9979 7.75001C11.9979 7.75002 11.9984 7.75003 11.9994 7.75007C12.0293 7.75103 12.479 7.76554 12.9146 7.98332C13.1381 8.09509 13.3388 8.25096 13.4853 8.47072C13.6287 8.68578 13.75 9.00624 13.75 9.5C13.75 9.99376 13.6287 10.3142 13.4853 10.5293C13.3388 10.749 13.1381 10.9049 12.9146 11.0167C12.6881 11.1299 12.4526 11.1903 12.2673 11.2211C12.1765 11.2363 12.1024 11.2436 12.054 11.247C12.0299 11.2487 12.0126 11.2495 12.0031 11.2498L11.9959 11.25Z" fill="currentColor"/>
</svg>
''',
colorFilter:
color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
width: width,
height: height,
);