What’s new in Dart 2.17

Ahmad Fayyas
3 min readMay 13, 2022

--

Dart Logo

Flutter 3.0 is out there!

Google released Flutter SDK 3.0! No doubt there is a lot of excitement for seeing what’s new there, how it will make the development processes to be smoother, what are the performance improvements, how to support multiple cross-platforms easily with a single source code, what are the new widgets, and more.

And… What about Dart?

A newer Dart version 2.17 comes with Flutter 3.0. It seems there are some of the added “cool” features and enhancements to Dart as well, let’s take a look!

But why bother?

My current Dart knowledge is enough to let me do the job.

Are you one of us? What a legend 🤖.

For some reason, the part of the “programming language” itself is getting skipped a lot. However, It’s also important to know what’s new in the language used in the Flutter framework. It’s like any language, the more vocabulary we know the more we are able to communicate.

Ideally, we try not to miss knowing some of the “cool” language features that could make our life easier by “doing things” faster as well as writing more robust code. It also helps avoid the:

Oh! So… I’m able to achieve it in a couple of lines while I’m writing a whole bunch of things. Well, 💩.

Plus, Dart sounds like a friendly programming language, why not have a better relationship with it 💙?!

Dart Reaction

So, What’s new in Dart 2.17?

Enumeration enchantments

If you are familiar with any programming language with “powerful” enums, you are already aware of its sweetness. Dart enums have the same sweet taste now 🍭!

Examples:

Since there are many things to mention, I preferred to split the code into multiple code snippets with different examples rather than having a single huge one. Let’s hope it’d make it more clear 😅.

  • Enum contains a getter and the overridden toString() method:
  • Enum implements an interface:
  • Enum contains a constructor and final fields (Enums can only declare final fields):
  • Enum applies a mixin:
  • Finally, enums are still able to have extensions:

Named Arguments, Anywhere!

Previously, the named arguments had to be at end of the list of arguments, but not anymore 🎉! Now it’s possible to order the named and the positional arguments in whatever preferred way.

Examples:

  • A custom doSomething function that takes positional and named parameters:
  • One of the most popular ones, the Flutter Text widget constructor:

Super Constructors

Now there is less boilerplate code when it comes to the inherited class constructor. super can be used to implicitly pass a certain parameter to the superclass constructor. FYI, this feature reduced thousands of lines of code in the Flutter framework 🤯.

Example:

And That’s pretty much it!

For more information:

Thanks for Reading!

--

--

Ahmad Fayyas

Software Engineer. If I’m not in front of my pc coding or playing video games, you can find me hanging out with family and friends, or sleeping!