title: How to mock a static getter's return value in Dart or Flutter?
body: <p>I would like to figure out how to modify the return value of a static getter for my unit tests in Flutter and Dart.</p>
  
  <p>I'm unit testing a simple function:</p>
  
  <pre><code>  Future&lt;bool&gt; exampleFunc() async {
      if (Platform.isIOS) {
        // Do some iOS-specific things
        return false;
      } else if (Platform.isAndroid) {
        // Do some Android-specific things
        return true; // just as an example
      }
      throw 'Unexpected platform';
    }
  </code></pre>
  
  <p>And I would like to modify the return values of the static getters of a class: I would like to tweak <code>Platform.isIOS</code> and <code>Platform.isAndroid</code> return value for the different test cases.</p>
  
  <p>Please note that I know of workarounds for this issue, for example, I could split the function into two functions (one for each platform), I could inject my own <code>enum</code> (or in this case, even a <code>bool</code> might work) that represents the supported platforms. In this example, I am actually going to do that, but I would like to know how to "modify" the return values of the <code>Platform</code> class's getters, because sometimes, you don't want to modify the signature of a function, as others might depend on it and yet, you still want to unit test the function.</p>