Leave a rating/review
Notes: 19. Learn Other Language Features
We’re finally getting to the end of the course, but being this wasn’t a comprehensive course, there’s still a lot of Dart features left to learn. I thought I’d give you an overview of topics that are still very important but weren’t covered in the entire Programming with Dart series.
First we have try-catch. Sometimes, you’ll be working with code that may cause an error. For example, you may try to save a file, but the user may have a full hard drive, or the drive may be disconnected. In such cases, you’d get an exception. This is an error that will crash your program. With try-catch, we can handle errors that gracefully manage the error such as stopping the operation and informing the user.
Next, we have asynchronous programming. Often times, you’ll want to do an action that may take time. By using concurrency, you can do that work in the background while your program still runs in the foreground. This is a large topic which we most likely cover in whole other course so stay tuned.
Then we have class extensions. With class extensions, we can add other methods to existing classes. This allows us to add code to other classes without having access to the source code itself. This is a great way to add code to existing types that makes it easy to use.
Assert is another feature that wasn’t covered. When write code, you often have several assumptions about it. For instance, you may assume that a number is always positive. Assertions check these assumptions. During development, if an assertion proves true, the program flow will be disrupted. This lets you check your code. In a production environment, assertions are ignored.
Memory management isn’t so much a language feature but it is important to keep in mind. When you assign values to variables and create objects, you are storing that data in memory so it’s quite important to understand how Dart manages its memory. Dart uses what is known as a garbage collector. That is, it cleans up unused memory in the background. Of course, such an automated process isn’t free as it takes cpu resources and battery life so knowing to how to manage the garbage collector is going to be a good long term strategy in your Dart and Flutter career.
Finally we have the dart core libraries. These libraries contain a ton of prewritten code to use in your programs. Chances are if you are looking to do something, someone else has already done it and it may be in the core libraries. So check them out.
A great way to get an overview of all the Dart language features is head over to the Dart language tour so you can get a roundup at was is available but also make sure to keep an eye on Dart development in general because while the language is ten years old, it is gaining new features every year.