i have some problem with body in this code. at first there was only email and password,
login() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final response = await http.post(
"https://api.batulimee.com//v1_ship/login_app",
body:{
"email": email,
"password": password,
"apikey": apikey,
}),
);
final data = jsonDecode(response.body);
String status = data['status'];
String pesan = data['message'];
if (status == "success") {
prefs.setString('stringValue', "apikey");
Navigator.of(context).pushReplacement(PageRouteBuilder(
pageBuilder: (_, __, ___) => new bottomNavBar(),
transitionDuration: Duration(milliseconds: 600),
transitionsBuilder:
(_, Animation<double> animation, __, Widget child) {
return Opacity(
opacity: animation.value,
child: child,
);
}));
print(pesan);
print(apikey);
} else {
print(pesan);
}
}
and when i add apikey variable then try to login, i got an error like this.
Exception has occurred. NoSuchMethodError (NoSuchMethodError: The getter 'length' was called on null. Receiver: null Tried calling: length)
how should i put that apikey?