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="M24 42C33.9411 42 42 33.9411 42 24C42 14.0589 33.9411 6 24 6C14.0589 6 6 14.0589 6 24C6 33.9411 14.0589 42 24 42ZM24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z" fill="black"/>
<path d="M31.6631 12.3027C33.6894 13.8676 35 16.2296 35 19.2903C35 22.8107 33.0456 25.2437 30.8102 26.7355C29.2829 27.7547 27.5519 28.395 26 28.7291V30C26 31.1046 25.1046 32 24 32C22.8954 32 22 31.1046 22 30V27C22 25.9444 22.8203 25.0706 23.8738 25.004C25.1758 24.9217 27.0744 24.4196 28.5898 23.4083C30.0544 22.4309 31 21.1102 31 19.2903C31 17.4962 30.2856 16.2929 29.2181 15.4684C28.0852 14.5934 26.4424 14.0721 24.6041 14.0069C22.7734 13.9419 20.9308 14.3379 19.5007 15.0879C18.0704 15.838 17.2151 16.8431 16.9415 17.9496C16.6765 19.0219 15.5923 19.6763 14.52 19.4112C13.4478 19.1462 12.7934 18.062 13.0584 16.9897C13.6849 14.4553 15.5296 12.6538 17.643 11.5455C19.7567 10.4369 22.3015 9.92266 24.7459 10.0094C27.1825 10.0958 29.7023 10.7882 31.6631 12.3027Z" fill="black"/>
<path d="M22 36C22 34.8954 22.8954 34 24 34C25.1045 34 26 34.8954 26 36C26 37.1046 25.1045 38 24 38C22.8954 38 22 37.1046 22 36Z" fill="black"/>
</svg>
''',
      colorFilter:
          color != null ? widgets.ColorFilter.mode(color!, widgets.BlendMode.srcIn) : null,
      width: width,
      height: height,
    );