build method

  1. @override
Widget build(
  1. BuildContext context
)
override

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:

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 6V34H28.3871V32H8V8H35V10.12H37V6H6ZM37 16C37 17.1046 36.1046 18 35 18C33.8954 18 33 17.1046 33 16C33 14.8954 33.8954 14 35 14C36.1046 14 37 14.8954 37 16ZM39 16C39 18.2091 37.2091 20 35 20C32.7909 20 31 18.2091 31 16C31 13.7909 32.7909 12 35 12C37.2091 12 39 13.7909 39 16Z" fill="black"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M30.0925 21.8293C30.6505 21.297 31.3921 21 32.1633 21H36.2449C37.7088 21 39.0718 21.4982 40.1221 22.4899C41.1327 23.4441 41.658 24.6669 41.8731 25.8258C42.2112 27.6476 41.8608 29.6391 41.0001 31.4036V39.5C41.0001 40.8008 40.0027 41.8842 38.7063 41.9915C37.41 42.0988 36.248 41.1941 36.0341 39.911L35.5001 36.7069L34.9661 39.911C34.7523 41.1941 33.5902 42.0988 32.2939 41.9915C30.9976 41.8842 30.0001 40.8008 30.0001 39.5V33.5042C30 33.4995 30 33.4948 30 33.49V30.0927C29.5475 30.3539 29.0308 30.4946 28.5 30.4946H23.3979C21.7411 30.4946 20.3979 29.1515 20.3979 27.4946C20.3979 25.8378 21.7411 24.4946 23.3979 24.4946H27.2986L30.0925 21.8293ZM32 33.4758C32.0001 33.4805 32.0001 33.4852 32.0001 33.49V39.5C32.0001 39.7602 32.1996 39.9768 32.4589 39.9983C32.7181 40.0198 32.9505 39.8388 32.9933 39.5822L34.0361 33.3256C34.1164 32.8434 34.5336 32.49 35.0225 32.49H35.9778C36.4666 32.49 36.8838 32.8434 36.9642 33.3256L38.0069 39.5822C38.0497 39.8388 38.2821 40.0198 38.5414 39.9983C38.8006 39.9768 39.0001 39.7602 39.0001 39.5V31.1665C39.0001 31.0065 39.0385 30.8488 39.1122 30.7066C39.8844 29.2157 40.165 27.5827 39.9067 26.1908C39.7498 25.3454 39.383 24.5427 38.749 23.9441C38.1018 23.333 37.2438 23 36.2449 23H32.1637C31.9066 23 31.659 23.099 31.473 23.2764L28.3893 26.2182C28.2033 26.3956 27.9561 26.4946 27.699 26.4946H23.3979C22.8457 26.4946 22.3979 26.9423 22.3979 27.4946C22.3979 28.0469 22.8457 28.4946 23.3979 28.4946H28.5C28.7571 28.4946 29.0043 28.3956 29.1903 28.2182L30.3098 27.1502C30.5993 26.874 31.0257 26.797 31.3936 26.9545C31.7614 27.112 32 27.4736 32 27.8738V33.4758Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );