signalr_client icon indicating copy to clipboard operation
signalr_client copied to clipboard

Handle Lists from backend

Open whysocket opened this issue 2 years ago • 0 comments

Hi, how can I handle lists from the backend. I have a List of string and I want to parse to dart objects.

The backend consists of returning a list of strings

 private static readonly Dictionary<string, string> userLookup = new();
 await Clients.All.SendAsync(
   Messages.USER.JOINED,
   JsonConvert.SerializeObject(userLookup.Select(x => x.Value)));

The frontend

 hubHelper.hubConnection.on('USER_JOINED', (args) {
    var response = args![0]! as List<String>;
    print(response);
  });
image

I can do the trim, but it's not supposed to deserialize the object into a List<String> in dart?

whysocket avatar Aug 03 '23 19:08 whysocket