I created a class called "Service" that has a Dio instance called http..
Class Service {
Dio http = Dio(
BaseOptions(
baseUrl: 'http://10.0.2.2/api',
),
);
}
And then I created a subclass of the Service class called AuthenticationService which I serve it with Provider so I can access it anywhere. Then I called the function from the subclass like this
Class AuthenticationService extends Service {
Future<String?> SignIn({String? email, String? Password}) async {
Response? response;
try {
response = await http.post('/auth/login', data: { 'email': email, 'password': password });
} catch(e) {
print(e);
}
return response?.data.toString(); //token
}
}
Then I called it from my widget
print('Passed!') // Passed
await context.read<AuthenticationService>().signIn(
email: _emailController.text,
password: _passwordController.text,
);
print('Passed?') // Never printed
Is there anything I miss? any suggestion or solution will help.. thank you
(PS: I did check my backend and it also never made it there)