I want to read a file from an asset during widget build with help of rootBundle but when I tried to call rootBundle.loadString('assets/myJsonAsset.json') like below :
testWidgets('load assets', (WidgetTester tester) async {
final result = await rootBundle.loadString('assets/myJsonAsset.json');
//above loadString method never return any result
expect(result, isA<String>());
});
Unable to load asset: assets/myJsonAsset.json
And the rootBundle.loadString('assets/myJsonAsset.json') never return any result.
Try to add this line to be executed before your tests:
This function will make your assets available for tests