I am trying to test a function which makes an api call and save that data into shared preferences. I am mocking my api call but in that function when i am trying to get instance of shared preferences I am getting this error:
MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
This is my test case code.
main() {
// setup
group("Login", () {
setUp(() {
flutterTest.TestWidgetsFlutterBinding.ensureInitialized();
});
test("Valid Creds Login", () async {
final validRes = ExpectedResponses.login();
final client = MockClient((request) async {
final res = json.encode(validRes);
return Response(res, 200);
});
ApiController.init(client);
final user = await ApiController.login(
email: "abc@gmail.com", password: "12345678");
expectAsync0(() {
expect(user.id, "1763");
});
}, skip: false);
});
}