代码:
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/services.dart';
void main() {
String abiStringFile="";
String path = "assets/data.json";
setUp(() async {
abiStringFile = await rootBundle.loadString(path);
});
test("Run Please", (){
print(abiStringFile);
});
}
错误:
Null check operator used on a null value.
Problem in PlatfromAssetBundle.load from services/asset_bundle.dart:223
pubspec.yaml文件
flutter:
uses-material-design: true
assets:
- assets/data.json
尝试在SetUp()
:的开头写入
TestWidgetsFlutterBinding.ensureInitialized();