Dart null safety in Action | Workshop

Flutter · 30K views · 2021 · 42:11

Open on YouTube

Programming language designSoftware practice, open source & careerstutorial

Why Stack Overflow recommends it

Stack Overflow users link it when answering Flutter and Dart questions that stem from null safety errors, as a learning resource and as an example of how the compiler reasons about nullable values.

Recommended by 2 people across 2 different months, 2021 to 2022.

What it is

A 42-minute Google I/O 2021 workshop by Andrew Brogdon of the Flutter team on Dart's null safety. It starts with simple examples of what null safety means and moves to advanced patterns such as lazy initialization and late circular references.

What people said

Recommends Rohan Thacker · 2021-06 · Stack Overflow · on “The named parameter isn't defined:”

A learning resource for flutter or dart where they are using null-safety to teach? Good question :) But Unfortunately I don't. As its been launched recently there isn't much available right now, the best I can share with you is Dart null safety in Action | Workshop [this video]

Recommends Ward Suleiman · 2021-07 · Stack Overflow · on “How can I update/add new information to my local JSOn file in Flutter? (without creating any classes)”

Oh, my bad, I should have enabled null safety on dart pad !! I will update the answer. But as advice check out this video about null safety as it becomes the default in flutter projects link [this video]

Cites Ward Suleiman · 2021-07 · Stack Overflow · on “Flutter getting error declaring Future variable and giving it a return value of method”

I will go ahead of my self and assume you are using Null Saftey (got that from your error message). Just add late keyword to your Future declaration, just like that: late Future summonerFuture; In case you are wondring what is late, it is a new keyword introduced with null saftey and it is job is to delay the initialisation of the variable. If you are intrested in knowing more about null saftey, check this video [this video] Sorry for the format, wrote it on my phone.

Cites Omar Sharaki · 2022-04 · Stack Overflow · on “Null check doesn't cause type promotion in Dart”

Please correct me if I'm wrong, but unless I'm missing something fundamental here, I feel that this example doesn't really illustrate the reasoning behind preventing getter promotion, since `i` obviously never changes after the null check. Wouldn't a better example for `i` in `Bar` be `int? get i => Random().nextBool() ? 0 : null;` like the one shown here [this video] ? This way, you can really see how the compiler could never guarantee that `i` isn't null, since its value can change to null when it's accessed after the null check.