Thank you very much for reading this far. You can find the sample of this article here. If you want, you can take a look at the official blog post to see all these improvements and the rest of the new features that this new version of Dart offers. In this article we have seen 3 of the improvements applied in Dart 2.17. If I try to alter the order of the parameters the compiler will give me an error: // In previous versions of Dart, named parameters // have to be at the end Also in this case when we declare a ColorWidget we have to pass the key parameter at the end, since it is a named parameter. We will change this later so that we will do the same thing with less code. 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. I will use these values later to be able to paint the container and to display the name of the color.īefore Dart 2.17, the only way to be able to add values to an enum is by using extensions.Įach of the three fragments shown in the previous screenshot is represented by the following widget: class ColorWidget extends StatelessWidget) : super(key: key) A newer Dart version 2.17 comes with Flutter 3.0. To determine the color and its name I use the following enum: import 'package:flutter/material.dart' Īs you can see, this enum defines what color it is, and through an extension I add its name and what MaterialColor it refers to. It consists of 3 different parts painted in a different color, with the name of the color in the center of the container. To start with, I'll show you the test application I've created in the previous version of Flutter, version 2.10.5: Flutter 2 ![]() Then I am going to update it to Flutter 3 and I will show you the changes that we should make to this application to apply each one of these improvements, in this graphical way you will easily understand what are those changes and how you can benefit from them in your applications developed with Flutter 3 and Dart 2.17. The next step is to upgrade to Flutter 3 and start using Dart 2.17 to apply the new improvements. In order to easily see and understand what are these improvements, I am going to present you a very simple application created with Flutter 2. ![]() In this article I am going to delve into the most notable improvements that Dart 2.17 brings, which is the enhancement of enums, the super initializers and the removal of order constraint for named parameters. In this blog I have previously covered the incredible performance improvements affecting Flutter for web apps and the possibility of running macOS applications natively in Apple Silicon processors.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |