O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Posting JSON-formatted data

This is a recipe for a client web app that sends a request to a web server. The request contains the form's data that is posted in the JSON format.

How to do it...

Look at the project post_form for the code.

  1. Our form (refer the next diagram) will post data for a job in IT; we reuse the class Job in the Making toJSON and fromJSON methods in your class recipe from Chapter 4, Object Orientation. We keep the example short and simple, but add two new properties, posted and open. Have a look at the following code:
    class Job { String type; int salary; String company; DateTime posted; // date of publication of job bool open = true; // is job still vacant ? Job(this.type, this.salary, this.company, this.posted); // toJSON and fromJSON ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required