3Learning Dart Basics

WHAT YOU WILL LEARN IN THIS CHAPTER

  • Why you use Dart
  • How to comment code
  • How to use the top‐level main() function
  • How to reference variables such as numbers, strings, Booleans, lists, maps, and runes
  • How common flow statements (such as if, for, while, and the ternary operator), loops, and switch and case work
  • How functions are used to group reusable logic
  • How to use the import statement for external packages, libraries or classes
  • How to create classes
  • How to use asynchronous programming to avoid blocking the user interface

Dart is the foundation of learning to develop Flutter projects. In this chapter, you'll start understanding Dart's basic structure. In future chapters, you'll create apps that implement these concepts. All the sample code is in the ch3_dart_basics folder. (In the sample code, don't worry about how it's laid out; just take a look so you can see how Dart code is written. Tap the floating action button located on the bottom right to see log results.)

WHY USE DART?

Before you can start developing Flutter apps, you need to understand the programming language used, namely, Dart. Google created Dart and uses it internally with some of its big products such as Google AdWords. Made available publicly in 2011, Dart is used to build mobile, web, and server applications. Dart is productive, fast, portable, approachable, and most of all reactive.

Dart is an object‐oriented programming (OOP) language, has a class‐based style, and uses a C‐style ...

Get Beginning Flutter now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.