title: Differences of using ThemeExtension vs class with static theme
body: <p>Flutter 3 is out and I've been experimenting a little.</p>
  <p>I have used the <code>ThemeExtension</code></p>
  <p><strong>yt ref:</strong> <a href="https://www.youtube.com/watch?v=8-szcYzFVao" rel="nofollow noreferrer">https://www.youtube.com/watch?v=8-szcYzFVao</a></p>
  <p><strong>api ref:</strong> <a href="https://api.flutter.dev/flutter/material/ThemeData/extensions.html" rel="nofollow noreferrer">https://api.flutter.dev/flutter/material/ThemeData/extensions.html</a></p>
  <p>and its great. However I'm starting to realize and ask myself I could have done the same result if I created a class with <code>static const</code> as properties such as colors, textstyles or any related theming.</p>
  <p>Can someone enlighten me if why I should use <code>ThemeExtensions</code> instead?</p>
  <p>Static class way:</p>
  <pre class="lang-dart prettyprint-override"><code>
  // Setup
  class AppColors {
    static const primaryColor = Color(0xFFFFFF);
    static const secondaryColor = Color(0xFFFFFF);
  }
  
  
  // Use case inside build
  
  return Container(
    child: Text('Hello world'),
    color: AppColors.primaryColor,
  )
  
  
  </code></pre>
  <p>ThemeExtension Way</p>
  <pre class="lang-dart prettyprint-override"><code>
  // Setup
  class AppColors extends ThemeExtension&lt;AppColors&gt;{
    final Color primaryColor;
    final Color secondaryColor;
  
    AppColors(this.primaryColor, this.secondaryColor);
  
    // .
    // ..
    // ... some @overrides such as copyWith() and lerp()
  }
  
  
  // Use case inside build
  
  final colors = Theme.of(context).extensions&lt;AppColors&gt;()!;
  
  return Container(
    child: Text('Hello world'),
    color: colors.primaryColor,
  )
  
  </code></pre>
  <p>As you can see here setting up for <code>ThemeExtension</code> is quite huge compared on using just the static classes for theme to achieve the same result.</p>