Getting Started with Dart
- Introduction
- Read the Dart language tour
- Dart language CodeLabs
- Study Questions
- Homework Assignment 1
Introduction
Dart is an object-oriented programming language with a syntax similar to Python and Java. This lab will get you started on the basic elements of the Dart language so that you can begin to build Flutter applications.
Read the Dart language tour
Read through the official documentation page A tour of the Dart language. This is a huge page, and you are not expected to remember everything.
Your goals are:
- Look for familiar tasks from your previous languages, like how to define variables, the structure of basic expressions, how to define methods, etc.
- Take note of the new or unusual things.
- Understand Dart’s concept of null-safety. Null-safety does not exist in the default implementations of Python or Java, but it is something you will have to deal with in Dart.
We are not going to be using everything on this page. Bookmark this page in your web browser and come back to it any time you think “How do you do X in Dart?”
Dart language CodeLabs
Now it is time to do some work. You will be using Gooogle’s CodeLabs platform to complete some programming exercises. You complete the CodeLabs in a programming environment in the browser, not in your Flutter project.
Visit https://dart.dev/codelabs/dart-cheatsheet. This is another page you will want to bookmark. Do the following:
- Work through the [Dart cheatsheet codelab]This code lab can be completed into the browser using the “DartPad” links.
- Work through the CodeLab on Null safety
Study Questions
- What is null-safety? Why is it important?
- How do you define a function in Dart?
- Which Dart function prints output to the screen?
- What is the
var
type? Arevar x = 5
andint x = 5
effectively the same? - What does the variable declaration
int? year
imply? - How do you call a constructor on a Dart class?
- What goes at the end of every Dart statement?
- When should you use
//
vs.///
for commenting? See also https://dart.dev/guides/language/effective-dart/documentation - What are the conventions for naming Dart classes, functions, and variables?
Homework Assignment 1
You are now ready to make some inroads on your first homework assignment. Check Canvas for details.