title: How to get the primary color's text color (onPrimary)?
body: <p>I'm setting my theme this way:</p>
  
  <pre class="lang-dart prettyprint-override"><code>theme: ThemeData(
    primaryColor: themeModel.primaryColor,
    ...
  ),
  </code></pre>
  
  <p>Yes, is dynamic.</p>
  
  <p>The problem is: if the user set, let's say, <code>indigo[100]</code>, some items (like the <code>bottomAppBar</code>) has light icons over that light color (so bad visibility).</p>
  
  <p>I thought the items adapt their text color to the given color property but it doesn't seem to work that way.</p>
  
  <p>So, I have to set that property manually. But I can't find the <code>Theme</code> property for text color on primary color (named <code>onPrimary</code> in material documentation).</p>
  
  <p>What I found is <code>Theme.of(context).colorScheme.onPrimary</code> but it doesn't seem to work well. It's always returning the same color.</p>
  
  <p>I know I can just get the contrast color for the primary color and set it like this:</p>
  
  <pre class="lang-dart prettyprint-override"><code>theme: ThemeData.from(
    colorScheme: ColorScheme(
      primary: themeModel.primaryColor
      onPrimary: themeModel.onPrimaryColor
      ...
    )
  )
  </code></pre>
  
  <p>But I'm sure Flutter is intelligent enough to autogenerate those properties if you don't pass them... isn't it?</p>
  
  <p>Another thing that I found is <code>Theme.of(context).primaryIconTheme.color</code>. <strong>That property is returning the color I'm looking for.</strong> But as its name states, it's supposed to be applied only to icons, not text, even when they would probably return the same black variant.</p>
  
  <hr>
  
  <h2>What I would like to know</h2>
  
  <p><strong>Is it the way it's supposed to work?</strong> Should I write myself the <code>onPrimary</code> property? Is it OK for code quality to use the <code>primaryIconTheme.color</code> for text colors? <strong>Or am I missing something?</strong></p>