Untitled

mail@pastecode.io avatar
unknown
dart
2 months ago
393 B
3
Indexable
Never
Future<User> getUserInfo() async {
    final SharedPreferences prefs = await SharedPreferences.getInstance();

    Map<String, dynamic> userMap = {};
    final String? userStr = prefs.getString('user');
    if (userStr != null) {
      userMap = jsonDecode(userStr) as Map<String, dynamic>;
    }

    final User user = User.fromJson(userMap);
    print(user);
    return user;
  }
Leave a Comment