I'm trying to compare an object to a string the user has inputted. the object is from a json api response I've mapped. I get the error on "if":
MaterialButton(
child: Text("Connect"),
textColor: Colors.black,
onPressed: (){
fetchUser().then((user)=> (if user.username == username){
return Get.toNamed('/home');
});
},
color: Colors.grey[350],
)
here is the function
Future <User>fetchUser() async{
var authresponse = await http.get(userCall);
if (authresponse.statusCode == 200){
var jsondata = jsonDecode(authresponse.body);
final data = apicallFromJson(jsondata);
var user = data.subsonicResponse.user;
return user;
}else{
throw Exception("Unable to connect to server, try again");}
}
``