re: Build a chat application in Dart 2 (Part 1) VIEW POST


Hi Jermaine, I faced a small problem while re-doing your tutorial. Even though this worked the first time, now the code in the server.dart file is giving weird result. Apparently the payload in the request is being converted wrongly:

    String data = await request.transform(Utf8Decoder()).join();
    var data = Uri.splitQueryString(payload);

    /* Prints this:
            "username": "Ratul"
        }: }

As you can see, Uri.splitQueryString is making the whole payload the key of the map it returns. I did fix the problem by using json.decode() method, but can you kindly explain what is happening here?


Hey Ratul, the snippet you're providing looks different. You have String data instead of String payload. What does your code for the section in question look like?


I think I misused a function down the line and this happened. I reverted everything back and rewrote the signin handler and it fixed the issue. I was trying out posting JSON data instead of form data and may have used a wrong method.
Oh and I just renamed payload to data for my convenience.

Thanks for the reply :D Eagerly waiting for the third part of the series!

code of conduct - report abuse