I use GetStorage to store user data
, I want to read its data in user profile GetxController
class UserHomeController extends GetxController {
final box = GetStorage();
// I found this method **but** i can't convert it to object
// as User get user => (userFromJson(GetStorage().read<User>('user'))
String get userS => (GetStorage().read<String?>('user') ?? "");
@override
Future<void> onInit() async {
super.onInit();
}
Thanks
2
Answers
Check the below code, you can directly read the data using read method with key name: