Tour of Dart

 

Getting Started

DartPad

DartPad is setup like a typical IDE. There is:

  • An Editor pane on the left
  • A Run button to run code in the editor
  • A Console on the upper right showing output
  • An Info panel on the bottom right showing information highlighted code
  • A Samples dropdown to show some sample code
  • A Share button you can use to share DartPad files you’ve created

The main function is preceded by a return type, which in Dart is void, meaning nothing is returned. The parentheses after main indicate that this is a function definition, and the curly braces contain the body of the function. Inside main, you add the Dart code for your program.

Variables, Comments, and Data Types

The first thing we’ll add to main is a variable assignment statement. Variables hold the data that your program will work on. You can think of a variable like a box in your computer’s memory that holds a value. Each box has a name, the name for the variable. You use the var keyword in Dart to denote a variable.

Basic Dart Types

Dart Data Types

 

Operators

There are arithmetic operators, equality, increment and decrement, comparison, and logical operators.

print(42 < 43); // true
print(42 >= 43); // false
print(42 == 43); // false
print(42 != 43); // true 

 

Strings

The Dart string type is String. Strings are expressed in Dart using text surrounded by either single or double quotes.

var firstName = 'Albert';
String lastName = "Einstein";

Comments

Popular posts from this blog

Flutter : Introduction

How to release your Flutter app

Firebase Cloud Messaging