BeginnerFlutter

Easy Dart Cheat sheet

By September 17, 2019 November 7th, 2020 No Comments

It is been a while I started with Dart since I needed to jump into Flutter.

Coming from Java, Kotlin, Javascript, and changing frequently from one to another. It forced me to simplify the process of learning and moreover, the process of re-learning that language efficiently.

So I created for myself a little cheat sheet where I summarized the common basic usage of Dart.

I share here this beta version that still misses tones of things and probably contains many errors. But I hope it can help others! who like me need to learn and re-learn every time!

Let’s learn the basics!

If you are coming from Kotlin/Java/Javascript I’d summarize as follows:

  • ; is back! (for Kotliners)
  • Everything is an object, even null and functions
  • Default initialization to null
  • Dart has null awareness syntax.
  • Usage of Cascade .. and the ??
1

Collections

  • Collections are easy to create. [] for Lists, {} for Sets, {key:value} for Maps.
  • Usage of Spread operator or …?
  • Collection if, and Collection for syntax creating a collection.

 

Functions and Classes

  • Positional, Named, and Optional parameters are possible in Dart.
  • The shorthand for one line function ()=>expression

2 things to highlight on creating classes

  • Factory constructors
  • Initialize list

Inheritance

  • A Class can be used as an Interface just using implements
  • Usage of Mixins to help reuse code and avoid multiple inheritance problems.

Asynchrony

  • Usage of Futures are similar to Javascript. Simplifying with async/await
  • Streams, similar to other streams frameworks like Rx.

 

Extension methods

I wrote a new post about the extension methods here.

Let me know if you find any error, your thoughts If you think there is something important to include, or just tell me any other thing it came to your mind 😉

Ernie

Author Ernie

More posts by Ernie