Skip to content

Assets during test #8490

@lejard-h

Description

@lejard-h

We use an asset file to configure some feature inside our app.
So during test, we tried to access to it but we keep getting this error.

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.<fn>
  dart:collection                                             _HashVMBase&MapMixin&&_LinkedHashMapMixin.putIfAbsent
  package:flutter/src/services/asset_bundle.dart 142:27       CachingAssetBundle.loadString

I know that assets are not available during test, but can you at least return null if no assets ?

An other possibility would be to provide assets before test like tester.provideAsset(name, asset);

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: tests"flutter test", flutter_test, or one of our testsframeworkflutter/packages/flutter repository. See also f: labels.waiting for customer responseThe Flutter team cannot make further progress on this issue until the original reporter responds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions