У меня есть метод входа в моем провайдере.
Future<void> signIn(
String email, String password, BuildContext context) async {
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
final clientID = "com.super.app";
final body = "username=$email&password=$password&grant_type=password";
final String clientCredentials =
const Base64Encoder().convert("$clientID:".codeUnits);
try {
final http.Response response =
await http.post("http://localhost:8888/auth",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"Authorization": "Basic $clientCredentials"
},
body: body);
final jsonResponse = json.decode(response.body);
// if (jsonResponse["error"] != null) {
// throw HttpException(jsonResponse["error"]);
// }
_userId = 1;
_token = jsonResponse['access_token'];
_expiryDate = DateTime.now().add(
Duration(
seconds: jsonResponse['expires_in'],
),
);
_autoLogout();
notifyListeners();
final userData = json.encode(
{
'userId': 1,
'email': email,
'token': _token,
'expiryDate': _expiryDate.toIso8601String(),
},
);
sharedPreferences.setString('userData', userData);
} catch (error) {
print(error.toString()); //<-- misleading error
}
}
Все работает нормально, но когда пропущены неверные учетные данные, я получаю вводящую в заблуждение ошибку
flutter: NoSuchMethodError: The method '_mulFromInteger' was called on null.
Receiver: null
Tried calling: _mulFromInteger(1000000)
Серверная часть передача кода ошибки 400 и body {"error": "invalid client"}, но я получаю эту странную ошибку в качестве вывода. Так что же означает эта ошибка и почему я получаю ее вместо тела