Skip to content

[Flutter] When Should We Use "new" Keyword?

Last Updated on 2021-10-16 by Clay

"new" keyword

When I jumped into Flutter learning, what bothered me most at first was as stated in the title of this article: When should I use the new keyword? Some tutorial will add new for declaring variable, but some tutorials will not.

And these sample codes are workable.

The conclusion is: you can add new or not.

In Dart 2, the new keyword is optional. If you want, you can continue to ignore it, and this will not have effect on your program.

The following is the official description:


References


Read More

Tags:

Leave a Reply