With the release of Flutter 1.12, Dart 2.7 also arrives, adding a new long-awaited feature: extension methods.
Was 2019 the year of Dart? In January 2019 our readers voted and they said that they wanted to hear about Dart over other programming languages. Meanwhile, GitHub’s State of the Octoverse revealed Dart as the fastest-growing language according to the number of contributors.
Developed by Google, Dart is an open source, client-optimized language that can compile to JavaScript for the web or to ARM and x64 machine code for mobile, desktop, and backend.
Announcing the stable release of the Dart 2.7 SDK!
Support for extension methods, and technical previews for null safety, and a new package for handling strings with special characters.
Learn more here → https://t.co/Lyci3NLdhh pic.twitter.com/2abxSrUhXB
— Dart Language (@dart_lang) December 11, 2019
Let’s look at the release highlights and the two big new features.
Extension methods
The most anticipated addition arriving in 2.7 is the introduction of extension methods.
SEE ALSO: DevOpsCon Munich 2019 takeaways: Everyone is in Ops now & more
From the release announcement post by Product Manager Michael Thomsen:
Dart 2.7 adds a long-requested, powerful new language feature: extension methods. These enable you to add new functionality to any type — even types you don’t control — and have the brevity and auto-complete experience of regular method calls.
According to Thomsen, extension methods are resolved and dispatched statically and can have type variables. Extension methods help add functionality to libraries and work just as fast as calling static functions. Using extension methods is as simple as importing the library they are contained in.
View the guide to learn more about them and their API conflicts. Lasse Reichstein Holst Nielsen, one of the creators of the features, explains in-depth how to use extension methods in an article titled Dart Extension Methods Fundamentals.
Source : JAXenter