Dart Null Safety in Flutter

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. By Simone Alessandria.

4 (3) · 2 Reviews

Download materials
Save for later
Comments
Share

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

Part 1: Dart Null Safety in Flutter

01
Toggle description

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.

Toggle description

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.

Toggle description

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.

Toggle description

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.

Toggle description

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.

Toggle description

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.