title: How to create custom InlineSpans in Flutter?
body: <p>How can I reuse pieces of code of <code>InlineSpan</code> type (e.g. <code>TextSpan</code>, <code>WidgetSpan</code>).</p>
  
  <p>For example,</p>
  
  <pre><code>Text.rich(
    TextSpan(
      children: [
        WidgetSpan(...), // code I like to reuse
        ... // other stuff
      ],
    ),
  )
  </code></pre>
  
  <p>Of course I can write a function, that gives me this InlineSpan, like this:</p>
  
  <pre><code>InlineSpan myCustomWidgetSpan() {
    return WidgetSpan(...);
  }
  </code></pre>
  
  <p>This is technically ok, but usually I reuse parts of code by creating a class that extends some other Flutter class (like <code>StatelessWidget</code> or <code>StatefulWidget</code>).</p>
  
  <p>I think that there should be some more idiomatic approach to this. So what are the best practices for reusing code that produces <code>InlineSpan</code>?</p>