Error Trying To Store User Data Using Shared Preferences

  Kiến thức lập trình

I am trying to store user data after logging in using Shared Preferences but my code is giving me this error message:

The argument type 'Map<String, dynamic>' can't be assigned to the parameter type 'String'. 

Here is my code:

class UserPerfs
  static Future<void> saveUserPerfs(User userData) async
    SharedPreferences prefs = await SharedPreferences.getInstance();
    String userJsonData = jsonDecode(userData.toJson());
    await prefs.setString('currentUser', userJsonData);

How can I resolve this?