The Dart Programming Language in Five Minutes

A quick overview for those already familiar with similar languages, like Java, Kotlin, C++, and C#

Image for post
Image for post
Photo by Silvan Arnet on Unsplash
Image for post
Image for post
Dartpad.dev allows you to experiment with Dart from the browser —screenshot by author

Hello World

void main() {
print('Hello World!');
}

Dart code is compact

class Person {
String name;
int age;

Person(this.name, this.age);

int lieAboutMyAge() {
print("My name is $name, my age is ${age - 10}");
}

}
void main() {
final me = Person("Erik", 38);
var girlfriend = Person("Shannon", 30);

me.lieAboutMyAge();
}

Type Inference

Final and Const

Objects

if (age.isNegative) {
print("The age can not be negative, you fool!")
}

Private and public

Expressions and statements

Lists, Sets, and Maps

var myList = [1, 2, 3];
assert(myList.length == 3);
assert(myList[1] == 2);
var constantList = const [1, 2, 3];
constantList[1] = 1; // This causes an error!
var mySet = {'john', 'eric', 'martha'};
var elements = <String>{};
elements.add('fluorine');
var gifts = {
'first': 'partridge',
'second': 'turtledoves',
'fifth': 'golden rings'
};
gifts['fourth'] = 'calling birds';

Dart Package Manager

Conclusion

Written by

Software developer by day, writer at night. Author of python3.guide, where you can start learning Python today

Sign up for Tech Explained

By Programming with Erik

Short, low-volume newsletter to keep you up-to-date on my latest articles Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.