You try to demonstrate the use of "extension methods" as they are called, not just "extensions", as that is usually what a different concept for native coding using the target platform SDK on devices are called.

Problem with the way you implement it is that it doesn't really make much use of the real benefits of extension methods in the first place!

Everything you do involves approximately the same amount of typing as if you'd use a wrapper class for it like before 2.7.0.

Sure, there is a minor performance boost by not creating wrapper objects and do the call forwarding internally, but the main benefit of the extension methods are programmer centric, not compiler optimization.

Also, you fail to mention that extension methods in Dart depends on the use of static types only, mainly because of the performance benefits, equal to that of calling static functions, which is crucial.

You can’t invoke extension methods on variables of dynamic type, but they do work with Darts type inference, hence they can also be used with generics.

The Dart Documentation (awesome as always) gives a better example on the concrete benefits this can give:

This article by @lrhn here on Medium, covers the same subject, but in much more detail:

Senior Software Developer. Hard-Core Learning Addict.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store