Book Image

Learning Dart

Book Image

Learning Dart

Overview of this book

Table of Contents (19 chapters)
Learning Dart
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Using JSON web services


In this section, we code a web server that communicates with our clients and runs the todo app; the todo data is sent to and from the web server in the JSON string format. Spiral s06 consists of a server and a client part. To run it, first start the server (lib/server/server.dart) in Dart Editor or from the console; it runs when you see in the server.dart tab in Dart Editor: Listening for GET and POST on http://127.0.0.1:8080.

(If it does not run, navigate to Run | Manage Launches.) Then start one or more clients (web/app.html) in Dartium. Locally, the client still saves the data in IndexedDB. Our screen has two new buttons:

  • To server: The client converts the the data to the JSON format and sends it to the server, where the data is stored in the main memory (post data to server)

  • From server: An another client (on a different machine) can request the server data to update its local database (get data from server)

Server communication in Spiral s06

The following is the...