even after i have intitialized there is an error :
Late initialization error displayName
here is the code where i have set the value:
var displayName=jsondata["username"];
SharedPreferences prefs=await SharedPreferences.getInstance();
prefs.setString('displayName', displayName);
and in here is i am accesing the data:
late String displayName;
getData() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
displayName=prefs.getString('displayName')?? "0";
}
initState() {
getData();
super.initState();
}
and i dont know what is the issue? but on other screens it is working.