Необработанное исключение: тип «String» не является подтипом типа «int» индекса для API входа в системуAndroid

Форум для тех, кто программирует под Android
Гость
Необработанное исключение: тип «String» не является подтипом типа «int» индекса для API входа в систему

Сообщение Гость »


I'm trying to get the users data from the database and sign in to the app using state management whenever I'm pressing the login button this error occurs although I'm add the toString() to the id what can I do to resolve this problem

//this is the post function

postRequest(String url, Map data)async{ try{ var response = await http.post(Uri.parse(url), body: data); if(response.statusCode == 200){ var responsebody = jsonDecode (response.body); return responsebody ; }else{ print("Error ${response.body}"); } }catch(e){ print("Error catch $e"); } } this is the login response
if(response['status'] == "success"){ sharedpref.setString('id', response['data']['id'].toString()); sharedpref.setString('name', response['data']['name']); sharedpref.setString('password', response['data']['password']); if(response['data']['name'] == "admin"){ Navigator.of(context).pushNamedAndRemoveUntil("adminpage", (route) => false); }else{ Navigator.of(context).pushNamedAndRemoveUntil("home", (route) => false); } } }

Источник: https://stackoverflow.com/questions/781 ... -index-for

Вернуться в «Android»