I'm using flutter "path_provider" plugin. I needed an SQLite operation. My error test class doesn't find "getApplicationDocumentsDirectory" and return null. The application runs for simulator/real device any working no problem.
Looking for provider repository and test folder.I've tired test class example but the error persists.
const MethodChannel channel =
MethodChannel('plugins.flutter.io/path_provider');
channel.setMockMethodCallHandler((MethodCall methodCall) async {
log.add(methodCall);
return response;
});
test('user save data', () async {
var response = null;
//FIXME : directory return null
final Directory directory = await getApplicationDocumentsDirectory();
final model = UserWordInformation();
model.word = word;
model.know = 1;
final result = await dbHelper.insert(model.toMap());
expect(result, 1);
});
I expect return path folder for the device.Some path : "/Users/vb/Library/Developer/CoreSimulator/Devices/C5B3C94C-C774-4D0E-A19C-97AAF11BD9E3/data/Containers/Data/Application/0508712B-A138-483A-921E-B5EAE6DF149F/Documents"
Maybe you have forgotten to initialize your response
variable.
I had a similar issue with getApplicationDocumentsDirectory
in one of my unit tests.
MissingPluginException(No implementation found for method getApplicationDocumentsDirectory on channel plugins.flutter.io/path_provider)
Added the following code to the unit test file:
const MethodChannel channel = MethodChannel('plugins.flutter.io/path_provider');
channel.setMockMethodCallHandler((MethodCall methodCall) async {
return ".";
});
And now it finally works. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With