title: How to test a method that uses package_info in Flutter?
body: <p>I am writing a Flutter plugin that checks the Play Store or App Store to see if the app needs to be updated. I'm using the <code>package_info</code> package to determine the version of the app that the user has. My code looks like this:</p>
  
  <pre><code>getVersionStatus() {
      PackageInfo packageInfo = await PackageInfo.fromPlatform();
      localVersion = packageInfo.version;
      ...
  }
  </code></pre>
  
  <p>I want to test this method, but if it run it as a unit test the <code>fromPlatform</code> call just hangs and times out the test. Is there a more elegant way to solve this than passing in a <code>testing</code> boolean? I.e:</p>
  
  <pre><code>if (testing) {
      PackageInfo packageInfo = await PackageInfo.fromPlatform();
      localVersion = packageInfo.version;
  } else {
      localVersion = '0.0.0'
  }
  </code></pre>
  
  <p>Should the <code>package_info</code> package provide a way to catch errors? Is there a way to tell if the method is being run by a test? </p>