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="M44 24C44 35.0457 35.0457 44 24 44C12.9543 44 4 35.0457 4 24C4 12.9543 12.9543 4 24 4C35.0457 4 44 12.9543 44 24ZM40.9758 18C41.6391 19.8767 42 21.8962 42 24L33.6664 24C33.0439 23.9989 32.4409 24.2094 31.9529 24.5949C31.4649 24.9804 31.1205 25.5182 30.9704 26.1209L30.9696 26.1238L30.0811 29.7379C29.9805 30.1494 29.9734 30.5787 30.0603 30.9934C30.1471 31.4081 30.326 31.7984 30.5843 32.1345C30.8427 32.4707 31.1741 32.744 31.5543 32.9325C31.9345 33.1209 32.3528 33.2192 32.7772 33.2191H33.2155L34.2043 38.8301C31.3043 40.8294 27.7888 42 24 42C20.2545 42 16.7762 40.856 13.8954 38.8984L15.4252 30.313H16.4329C16.9755 30.3132 17.5107 30.189 17.998 29.9501C18.4853 29.7112 18.9116 29.364 19.2448 28.9352C19.578 28.5066 19.8094 28.0076 19.9219 27.4762C20.0345 26.9449 20.0252 26.3949 19.895 25.8676L18.6116 20.7053L18.6109 20.7024C18.4165 19.9302 17.971 19.2443 17.3438 18.7543C16.7168 18.2644 15.9444 17.9985 15.1489 18H7.02423C9.49525 11.0088 16.1627 6 24 6C25.3444 6 26.6543 6.14738 27.9146 6.42686L27.4816 7.8435H27.2925C26.9446 7.84341 26.6012 7.9225 26.2884 8.07479C25.9755 8.22714 25.7013 8.44876 25.4868 8.72289C25.2723 8.99701 25.123 9.31643 25.0504 9.65689C24.9778 9.99736 24.9837 10.3499 25.0678 10.6877C25.0838 10.7521 25.1062 10.8147 25.1346 10.8747L27.7448 16.3797C27.8828 16.8306 28.1569 17.2288 28.5308 17.5189C28.9338 17.8316 29.4295 18.0008 29.9394 18H40.9758ZM40.129 16C38.0355 11.7875 34.3403 8.5114 29.8403 6.96864L29.1779 9.13578C29.0494 9.55628 28.6613 9.8435 28.2216 9.8435H27.2925C27.2481 9.84348 27.2038 9.85358 27.1639 9.87301C27.124 9.89244 27.0891 9.92067 27.0618 9.95551C27.0345 9.99036 27.0156 10.0309 27.0064 10.0741C27.0017 10.0961 26.9996 10.1184 27.0001 10.1408L29.5877 15.5983C29.6155 15.6569 29.6375 15.718 29.6535 15.7809C29.6693 15.8435 29.7057 15.8991 29.7569 15.9388C29.8081 15.9786 29.8713 16.0001 29.9363 16L40.129 16ZM33.6632 26L41.8901 26C41.3897 30.5274 39.2101 34.5487 35.988 37.4274L35.0395 32.0456C34.9553 31.5676 34.54 31.2191 34.0547 31.2191H32.7772C32.6621 31.2192 32.5475 31.1926 32.4426 31.1406C32.3376 31.0885 32.2441 31.0121 32.17 30.9157C32.0959 30.8193 32.0434 30.7057 32.0178 30.5833C31.9922 30.4611 31.9943 30.3344 32.0238 30.2133L32.9111 26.6043L32.9114 26.6031C32.9558 26.4259 33.0561 26.2722 33.1928 26.1642C33.3294 26.0563 33.495 25.9996 33.6632 26ZM6.44603 20C6.15412 21.2864 6 22.6252 6 24C6 29.3841 8.36391 34.2161 12.1105 37.5147L13.6031 29.1376C13.6882 28.6605 14.103 28.313 14.5876 28.313H16.4329C16.6698 28.3131 16.9042 28.2589 17.1176 28.1543C17.331 28.0497 17.5186 27.8972 17.6656 27.708C17.8127 27.5187 17.9154 27.2978 17.9653 27.0618C18.0153 26.8261 18.0112 26.582 17.9535 26.3481L16.6714 21.1908L16.6711 21.1895C16.5847 20.8474 16.3876 20.5452 16.1124 20.3302C15.8371 20.1151 15.4991 19.9992 15.1521 20L6.44603 20Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );