<p dir="auto">We use an asset file to configure some feature inside our app.<br>
So during test, we tried to access to it but we keep getting this error.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="The getter 'buffer' was called on null.
  Receiver: null
  Tried calling: buffer
  dart:core                                                   Object.noSuchMethod
  package:flutter/src/services/asset_bundle.dart 148:29       CachingAssetBundle._fetchString
  ===== asynchronous gap ===========================
  package:flutter/src/services/asset_bundle.dart 142:50       CachingAssetBundle.loadString.&lt;fn&gt;
  dart:collection                                             _HashVMBase&amp;MapMixin&amp;&amp;_LinkedHashMapMixin.putIfAbsent
  package:flutter/src/services/asset_bundle.dart 142:27       CachingAssetBundle.loadString"><pre class="notranslate"><code class="notranslate">The getter 'buffer' was called on null.
  Receiver: null
  Tried calling: buffer
  dart:core                                                   Object.noSuchMethod
  package:flutter/src/services/asset_bundle.dart 148:29       CachingAssetBundle._fetchString
  ===== asynchronous gap ===========================
  package:flutter/src/services/asset_bundle.dart 142:50       CachingAssetBundle.loadString.&lt;fn&gt;
  dart:collection                                             _HashVMBase&amp;MapMixin&amp;&amp;_LinkedHashMapMixin.putIfAbsent
  package:flutter/src/services/asset_bundle.dart 142:27       CachingAssetBundle.loadString
</code></pre></div>
<p dir="auto">I know that assets are not available during test, but can you at least return null if no assets ?</p>
<p dir="auto">An other possibility would be to provide assets before test like <code class="notranslate">tester.provideAsset(name, asset)</code>;</p>
<p dir="auto">Its kind of a no-brainer that you might want to validate your assets in some way. Especially when you have multiple people working on the same project (not all of them developers). Furthermore its common to want to test the code that processes those assets, without having to hardcode versions of the assets in the tests, that might not match up with the live assets as they change through time. Finally of course, there is testing widgets that use the asset bundle, and need valid assets from it to behave properly.</p>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="211117306" data-permission-text="Title is private" data-url="https://github.com/flutter/flutter/issues/8490" data-hovercard-type="issue" data-hovercard-url="/flutter/flutter/issues/8490/hovercard" href="https://github.com/flutter/flutter/issues/8490">#8490</a> seems to confirm that reading assets during test is not possible.</p>