title: How mock a instance of File in Dart
body: <p>I want mock the method <code>file.writeAsBytes</code>, but I don't know how to make this.</p>
  <p>note: I do not intend to save the files in the test, just overwrite the method so that I can get the list of paths.</p>
  <p>Has anyone ever experienced this?</p>
  <p><strong>My code is</strong></p>
  <pre><code>class ShareHelper {
  
    static Future&lt;List&lt;String&gt;&gt; createFilesFromString(
            List&lt;FileShare&gt; files) async =&gt;
        Future.wait(
            files.map((fileShare) =&gt; _createFileFromString(fileShare)).toList());
  
    static Future&lt;String&gt; _createFileFromString(FileShare fileShare) async {
      final str = fileShare.base64.split(',');
      Uint8List bytes = base64.decode(str[1]);
      String dir = (await getTemporaryDirectory()).path;
  
      final fileName = _createFileName(fileShare.name);
  
      File file = File(
          &quot;$dir/&quot; + fileName);
      await file.writeAsBytes(bytes);
      return file.path;
    }
  }
  </code></pre>
  <p><strong>My unit test:</strong></p>
  <pre><code>    test('Deve compartilhar os arquivos', () async {
        PathProviderPlatform.instance = MockPathProviderPlatform();
  
        final files = [
          FileShare(name: 'Teste/A', base64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUg...'),
        ];
  
        final paths = await ShareHelper.createFilesFromString(files);
        expect(paths, []);
      });
  
    });
  </code></pre>