Dart Tutorial

Dart Chapter 13 of 15

Practical Dart

The everyday skills of real projects: JSON, HTTP requests, dates and times, regular expressions, command-line apps and testing.

You know the language. This chapter covers the tasks you will meet in almost every real project, whichever kind of app you build.

Lessons in this chapter

  1. Working with JSON in Dart: Encode, Decode and Model ClassesLearn JSON in Dart: jsonDecode and jsonEncode, converting to and from model classes with fromJson and toJson, lists and nested objects.
  2. HTTP Requests in Dart: GET, POST and Calling REST APIsLearn to call web APIs in Dart with the http package: GET and POST requests, headers, JSON bodies, status codes, errors and timeouts.
  3. Date and Time in Dart: DateTime and DurationWork with dates and times in Dart: create, parse, format, compare and calculate with DateTime and Duration, including UTC and time zones.
  4. Regular Expressions in Dart with RegExpLearn RegExp in Dart: test, find, extract and replace text with patterns, use groups and named groups, and validate input.
  5. Building Command-Line Apps in DartBuild command-line tools in Dart: read arguments and options with the args package, use stdin, stdout and exit codes, and compile to an executable.
  6. Unit Testing in Dart with package:testLearn unit testing in Dart: write tests with test and expect, group them, use matchers, test async code and exceptions, and run dart test.