This course is available as part of the raywenderlich.com Professional subscription. To learn more click here
Pro

Dart Null Safety in Flutter

Feb 8 2022 · Video Course (33 mins) · Beginner

All Flutter versions since Flutter 2 support Sound Null Safety. Strange as it may seem at first, this is to help you as a developer! In this course, see how to use Dart Null Safety to your advantage, and build apps faster and more reliably. Use null aware operators, the new “late” and “required” keywords, and understand how to automatically migrate your older null unsafe code to the newer Flutter versions.

Version

  • Flutter 2.5.1, Dart 2.14.1, All Platforms, Visual Studio Code 1.63.2

Dart Null Safety in Flutter

Learn what Null Safety is, why it can simplify your life as a developer, and see how to declare and use both nullable and non-nullable types in a Dartpad window.

1

Still using DartPad, see how to leverage “Type Promotion”. Dart can parse your code and understand that in some cases you can use nullable variables just like non-nullable ones.

2

See how to create a class parsing JSON data, and understand when and how to use the “late” keyword in your fields, and the “required” decorator in your constructors.

3

In an imperfect world, you sometimes retrieve imperfect data. In this episode, see how to deal with JSON data containing unexpected values, fixing a class that breaks when receiving null values. Also understand and use null-aware operators in your code.

4

Function parameters should also follow null safety rules. See how to pass nullable and non-nullable parameters to your functions, and how to deal with nullable data inside them.

5

In this episode, understand how to use the dart migrate command line tool to automatically upgrade your code to null safety. You will also see how to decide which parts of your project should be migrated, and how to annotate your code to guide the tool in making the best updates.

6

Who is this for?

Developers who want to understand and use Null Safety features in Flutter

Covered concepts

  • Nullable and Non-nullable types
  • Late and Required
  • Null-aware Operators
  • Type Promotion
  • Conditional Property Access
  • Dart migrate

Contributors

Comments