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 d="M14.9998 38V28.5909C13.9071 27.4645 11.9536 24.9707 11.2561 21.684C14.5386 22.1315 19.0286 22.4045 23.9642 22.4045C28.3971 22.4045 32.4705 22.1843 35.6325 21.8152C36.0838 22.9438 36.5168 24.0208 36.8863 24.9373C37.4172 26.254 36.4474 27.6896 35.0277 27.6896H34.4739V30.8341C34.4739 31.9387 33.5785 32.8341 32.4739 32.8341H27.9998V38H14.9998Z" fill="black"/>
<path d="M22.5416 10C14.4299 10 11.6488 14.7432 11.1052 18.041C9.78335 17.8525 8.67961 17.6349 7.84965 17.3959C7.8171 17.3866 7.78497 17.3772 7.75327 17.3677C6.70615 17.0561 6.12207 16.7091 6.12207 16.3433C6.12207 15.9776 6.70615 15.6306 7.75327 15.319C7.78497 15.3095 7.8171 15.3001 7.84965 15.2907C8.48727 15.1072 9.28649 14.9362 10.2221 14.7813C10.6049 14.1069 11.1667 13.3346 11.7677 12.54C11.5318 12.5693 11.3012 12.5993 11.076 12.6302C9.41884 12.8577 7.9764 13.1407 6.90689 13.4877C6.3859 13.6568 5.83306 13.8785 5.37048 14.1888C4.99757 14.4389 4.12207 15.126 4.12207 16.3433C4.12207 17.5607 4.99757 18.2477 5.37048 18.4979C5.83306 18.8081 6.3859 19.0299 6.90689 19.1989C7.9764 19.546 9.41884 19.829 11.076 20.0564C14.42 20.5154 18.9758 20.7923 23.9645 20.7923C28.9532 20.7923 33.5089 20.5154 36.8529 20.0564C38.5101 19.829 39.9526 19.546 41.0221 19.1989C41.5431 19.0299 42.0959 18.8081 42.5585 18.4979C42.9314 18.2477 43.8069 17.5607 43.8069 16.3433C43.8069 15.126 42.9314 14.4389 42.5585 14.1888C42.0959 13.8785 41.5431 13.6568 41.0221 13.4877C40.2077 13.2235 39.177 12.9963 38 12.8026V10L34 14L38 17.5V14.8311C38.8102 14.9726 39.5093 15.1266 40.0793 15.2907C40.1119 15.3001 40.144 15.3095 40.1757 15.319C41.2228 15.6306 41.8069 15.9776 41.8069 16.3433C41.8069 16.7091 41.2228 17.0561 40.1757 17.3677C40.144 17.3772 40.1119 17.3866 40.0793 17.3959C38.7572 17.7766 36.7403 18.103 34.2538 18.3443C33.7446 17.0522 33.2722 15.8382 32.9059 14.8693C32.6337 14.1494 32.1065 13.6687 31.4438 13.0645C31.3682 12.9956 31.2909 12.9251 31.212 12.8524C29.3686 11.1555 27.2688 10 22.5416 10Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );