I am testing a URL in flutter, but keep getting an error:
Error: The argument type 'String' can't be assigned to the parameter type 'int'. final loginUri = Uri.parse(Config.apiURL, Config.loginAPI); ^
class Config {
static const String appName = "appName";
static const String apiURL = http://127.0.0.1:8000/;
static const String loginAPI = "api/dj-rest-auth/login/";
}
class AuthService {
final loginUri = Uri.parse(Config.apiURL, Config.loginAPI);
The error is showing for Config.loginAPI
How do I fix this error knowing that they are both strings, not int related to them.
What is the reason for it and how to fix it?
CodePudding user response:
static const String apiURL = http://127.0.0.1:8000/;
This code is wrong.
Follow correct code.
static const String apiURL = "http://127.0.0.1:8000/";
CodePudding user response:
Try to change
class Config {
static const String appName = "appName";
static const String apiURL = http://127.0.0.1:8000/;
static const String loginAPI = "api/dj-rest-auth/login/";
}
class AuthService {
final loginUri = Uri.parse(Config.apiURL, Config.loginAPI);
to
class Config {
static const String appName = "appName";
static const String apiURL = "http://127.0.0.1:8000/";
static const String loginAPI = "api/dj-rest-auth/login/";
}
class AuthService {
final loginUri = Uri.parse(Config.apiURL, Config.loginAPI);