Hi I'm new to flutter and I'm struggling to use shared preference inside the builder method, Here is my code:
getId() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String sessionId = prefs.getString('sessionId');
return Text(sessionId);
}
This is a piece of my build method:
ListTile(
title: Text(
'Welcome, $getId()',
style: TextStyle(color: Colors.white),
),
Here's the error output that I get for trying to use the shared pref inside a text widget:
dynamic function closure flutter