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="M12.9665 7.00504C12.9637 5.34818 14.3047 4.00284 15.9615 4.00013L31.9337 3.97397C33.5906 3.97125 34.9359 5.3122 34.9386 6.96905L34.9943 40.9559C34.997 42.6128 33.6561 43.9581 31.9992 43.9608L16.027 43.987C14.3702 43.9897 13.0248 42.6488 13.0221 40.9919L12.9665 7.00504ZM14.9656 8.00168C14.9638 6.89711 15.8577 6.00021 16.9623 5.9984L30.9395 5.97551C32.0441 5.9737 32.941 6.86766 32.9428 7.97223L32.987 34.9621C32.9888 36.0666 32.0949 36.9635 30.9903 36.9653L17.0131 36.9882C15.9085 36.99 15.0116 36.0961 15.0098 34.9915L14.9656 8.00168ZM24.0099 41.9745C25.1131 41.9727 26.0059 41.0761 26.0041 39.9719C26.0023 38.8677 25.1065 37.974 24.0033 37.9758C22.9002 37.9776 22.0073 38.8742 22.0091 39.9784C22.0109 41.0826 22.9067 41.9763 24.0099 41.9745Z" fill="black"/>
<path d="M23.1923 27.5397L23.1921 27.5395C21.6033 26.2237 20.297 25.1418 19.3858 24.1243C18.4764 23.1088 17.9766 22.1747 17.9758 21.1568C17.9745 19.5006 19.3937 18.2 21.2042 18.1985C22.2283 18.1977 23.2141 18.6337 23.8572 19.3235L23.9744 19.4492L24.0914 19.3233C24.7334 18.6325 25.7184 18.1948 26.7426 18.194C28.553 18.1925 29.9744 19.4907 29.9758 21.147C29.9766 22.1648 29.4785 23.0998 28.5707 24.1175C27.6642 25.1337 26.3654 26.2153 24.7861 27.5305L24.7702 27.5437L24.7699 27.544L23.982 28.1963L23.1923 27.5397Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );