Null safety in Dart - Introduction

  Рет қаралды 164,901

Flutter

Flutter

Күн бұрын

Пікірлер: 260
@filiphracek
@filiphracek 3 жыл бұрын
I'm really sorry about my mispronunciation of "variable" and other English words. By the time I realized my error, it was too late to re-shoot. Apologies for butchering the English language. (Again.) I'll try to do better next time.
@valternegreiros4511
@valternegreiros4511 3 жыл бұрын
No worries
@sainoba1
@sainoba1 3 жыл бұрын
It actually gives it a little bit of a charm
@AlvarLagerlof
@AlvarLagerlof 3 жыл бұрын
Don't worry. I'm not native either. It's totally clear what you were meaning to say and the content is great!
@filiphracek
@filiphracek 3 жыл бұрын
Thanks all! I'm feeling a lot better about it. This community is so wonderful.
@emekachukumah7016
@emekachukumah7016 3 жыл бұрын
No need to apologize. Great video!
@josiahsaunders4936
@josiahsaunders4936 3 жыл бұрын
This is a beautiful thing. I can't imagine how hard it was to create this feature. Thank you flutter/dart devs :)
@stainly7529
@stainly7529 3 жыл бұрын
Yeah but it’s copied from other languages. Swift is the first to have it.
@robbet2477
@robbet2477 3 жыл бұрын
@@stainly7529 Bro the important thing is the improvement in the language, Swift has copied things from Java and C ++ 😜, but for that reason it is not necessary a Fanboy saying it everywhere, languages ​​are to solve problems, and developers use them as tools, create problems = bad programmer 🙄😒
@lx2222x
@lx2222x 3 жыл бұрын
It isn't hard at all, it is actually easier
@yiweima4412
@yiweima4412 3 жыл бұрын
@@lx2222x Yup, its not about difficulty, its about innovation. No matter how hard something is its still some what achievable, but if lack of innovation you cant even imagine it.
@pranjal86able
@pranjal86able 3 жыл бұрын
@@stainly7529 I have seen this idea been discussed before swift existed. Swift made it mainstream. Chris Lattner never claimed that swift/him invented this. Swift is awesome and so is dart imo.
@hatema
@hatema 3 жыл бұрын
Dart is a really good language and I hope it grows out of Flutter's shadow.
@promisenwanno5969
@promisenwanno5969 3 жыл бұрын
Yes, I think so too. It's one of those languages that was created with sense of reality. Just like javascript and php. Provides the needed and avoids unnecessary formalities.
@michasengotta2295
@michasengotta2295 3 жыл бұрын
@@promisenwanno5969 except JavaScript is a mess and Dart isn't
@androov2797
@androov2797 3 жыл бұрын
Eminem Fan, you got my support
@albertoazinar1209
@albertoazinar1209 2 жыл бұрын
This guy is really good at explaining Flutter stuff. Amazing video
@AltagraciaOlive
@AltagraciaOlive Ай бұрын
you are by far the best person explaining binary options! Thank you for putting these videos together. I look forward every week to see your videos!
@amirgamil
@amirgamil 3 жыл бұрын
I learnt about Flutter and Dart shortly after I started learning Kotlin. Not having null safety seemed like such a loss. Now that it'll be in Dart soon, I'm super happy to see that it'll be in Dart soon. And sound safety as well. Thanks Filip and the Flutter and Dart teams for all your hard work!
@ilkercankaya3779
@ilkercankaya3779 3 жыл бұрын
I was expecting this to arrive sooner or later. Things are very easy when it has null safety such as in kotlin.
@NextLevelCode
@NextLevelCode 3 жыл бұрын
Did you notice though that it has more in common with Swift than Kotlin? List at 2:47
3 жыл бұрын
I can't wait to be able to use this, I come from Kotlin and I totally miss this feature
@kishorekittu4800
@kishorekittu4800 3 жыл бұрын
Can anyone explain How this is different from the kotlin's null safety? What is this sound null safety and how is it different from the normal one?
@christiang.3616
@christiang.3616 3 жыл бұрын
Beautiful. This reminds of the time when I had to copy null-safety boilerplate code and paste through a number of dart files. Thank you Dart devs ❤❤
@IsaacLarbiOnline
@IsaacLarbiOnline 3 жыл бұрын
I sure will stay null safe, thanks for a down to earth presentation, you did a great job explaining.
@kherelable
@kherelable 3 жыл бұрын
I love you guys. Thank you for revive the joy of coding.
@mohamedoumast60
@mohamedoumast60 3 жыл бұрын
Thank you Flutter for the great effort to solve this old problem, now I can program safely, thank you
@user-v2eqj8xiz4l
@user-v2eqj8xiz4l 3 жыл бұрын
Since I coded with Dart, when I come across JavaScript & PHP variables, I ask myself what is this? what I supposed to do!? I love how dart make me unsafety on another language.
@vutuananh747
@vutuananh747 3 жыл бұрын
Totally same with Swift, but it's still awesome. Thanks Flutter team :D
@abigailchin9050
@abigailchin9050 3 жыл бұрын
The devil works hard to introduce null errors but the dart development team works harder 😂🙏🏼
@msjahun
@msjahun 3 жыл бұрын
😂🤣
@ymi_yugy3133
@ymi_yugy3133 3 жыл бұрын
I like the new syntax but it would have been nice to introduce the concept in a more general form, i.e. tagged union, or better yet also introduce tuples to give dart the full power of algebraic data types.
@algeriennesaffaires7017
@algeriennesaffaires7017 3 жыл бұрын
I wasn't able to understand what null safety mean but now i understand thank you
@promisenwanno5969
@promisenwanno5969 3 жыл бұрын
I love Dart! One of those languages that was created with sense of reality. Straight to the point without unnecessary formalities- just like javascript and php.
@atabayilker
@atabayilker 3 жыл бұрын
Null exceptions always happen and hurt a programmer's feelings :D nice feature. Loving the Dart and Flutter more and more everyday. Hopefully google never stops developing on this particular technology.
@meetpanchal8809
@meetpanchal8809 3 жыл бұрын
The introduction music is so soothing 😅
@bikashkalita8712
@bikashkalita8712 Ай бұрын
now i'm feeling better. u made it so easy.. thank you :)
@HenriqueMDerosa
@HenriqueMDerosa 3 жыл бұрын
Awesome video! Great! Thanks for that! 🌟
@pepepriest5973
@pepepriest5973 2 жыл бұрын
This really changed a lot from the last time i coded in dart
@samuellamanyeaglago6919
@samuellamanyeaglago6919 3 жыл бұрын
my 2 hour search is over. At long last, a question mark saved the day!
@sodiboo
@sodiboo 3 жыл бұрын
nice disclaimer at the start, i figure it's meant to be easy to remove with youtube's video editor on pre-uploaded videos? for anyone watching in the future when null safety is stable, remove about 15 seconds from any timestamps that seem to link to the wrong part of the video and see if it makes any more sense, since that disclaimer is about 15 seconds long
@DionisiusWahyuAdiSaputra
@DionisiusWahyuAdiSaputra 3 жыл бұрын
Thank you for the hard work! Keep it up :)
@donathmm3881
@donathmm3881 3 жыл бұрын
Awesome!!!!!!! Thank you google!!! Flutter and dart are the best! Syntax is exactly like in swift I love it 😍
@notaspectator
@notaspectator 3 жыл бұрын
If im not mistaken, this was one of the neat features of ruby and using question mark , also available in typescript
@hosseinazem520
@hosseinazem520 3 жыл бұрын
Nice thank u. i have a question. we should use ! when we guess maybe the value is null?
@valternegreiros4511
@valternegreiros4511 3 жыл бұрын
Better than Kotlin, thank you so much
@aadarsh8869
@aadarsh8869 3 жыл бұрын
Kotlin has also null saftety
@SEGVeenstra
@SEGVeenstra 3 жыл бұрын
@@aadarsh8869 think he is aiming for the sound null safety. Which indeed makes it better then Kotlin imo
@thedude61636
@thedude61636 3 жыл бұрын
@@SEGVeenstra what is null sound exactly I'm not sure I understand it
@SEGVeenstra
@SEGVeenstra 3 жыл бұрын
@@thedude61636 there is a difference in null-safety and sound null-safety. Kotlin is null-safe, which means you can declare fields to be non-nullable but technically things can still be null in some ways. We have it in a project that serializes Json. We can define properties as non-nullable, but it could still turn out to become null. With sound null-safety you are guaranteed it will never be null, allowing the compiler to be optimized. Swift for example is also sound null-safe.
@sindrenm
@sindrenm 3 жыл бұрын
@@SEGVeenstra So how exactly does Dart make sure that fields from a back-end API are null safe? Will it not allow non-null types from a network call, for instance?
@SibirianWolf1987
@SibirianWolf1987 Жыл бұрын
Very well explained!
@MaximoPower2024
@MaximoPower2024 3 жыл бұрын
Really interesting
@tdrkDev
@tdrkDev 3 жыл бұрын
Thank you for such informative and easy to understand guide 😁
@carloselilopeztellez7802
@carloselilopeztellez7802 3 жыл бұрын
Love the feature, awesome vid!
@heaven7pro
@heaven7pro Жыл бұрын
Great explanation! Thanks a lot
@amdsy0997
@amdsy0997 3 жыл бұрын
Thanks, very useful. And the best part that it looks almost identical to Swift.
@wandermonk1266
@wandermonk1266 3 жыл бұрын
Thanks for your explanation. What is your native language anyway?
@tananga1523
@tananga1523 3 жыл бұрын
Super video. Please create more news videos and tutorials.
@mohammadelkhatib
@mohammadelkhatib 3 жыл бұрын
Awesome Great feature from flutter team 👌
@MatthewPolack
@MatthewPolack 2 жыл бұрын
Thanks for this...there is a few of us taking a Beginner Flutter course with Angela Yu...and in one of the lesson she has us coding like this: void main() { greet(greeting: 'Hey', namePerson: 'Cindy'); } void greet({String namePerson, String greeting}){ print("$greeting $namePerson"); } But this now throws a Null error in the latest Dart.......us beginners in the comments note that we can fix this either by putting a '?' at the end of the String...or by placing the word 'required' before 'String'...but what should we do in this case ideally? Thanks for any clues if you have a moment!
@abdullahalmaruf5513
@abdullahalmaruf5513 3 жыл бұрын
Beautifuly explained. Thanks a lot 👍
@chordfunc3072
@chordfunc3072 3 жыл бұрын
This is going to be great! Can't wait for it to be out of beta!
@ninjaasmoke
@ninjaasmoke 3 жыл бұрын
Yes. YES. *YES* THANK YOU😭😭😭😭♥️♥️♥️♥️
@moazelsawaf2000
@moazelsawaf2000 2 жыл бұрын
Thanks a lot, great and simple video ❤
@VarunArora14
@VarunArora14 3 жыл бұрын
Hi. I have a question. If I fetch data as Json object from 'jsonplaceholder.typicode.com/albums' and show its contents after jsonDecode in listView builder with child: Text(drinks[index]['title']) where drinks is jsonDecode(response.body) then it gives error " An expression whose value can be 'null' must be null-checked before it can be dereferenced. Try checking that the value isn't 'null' before dereferencing it" and after putting the question mark after word 'drinks' removes the error. I tried searching about it but did find only declaration with question marks and null safety with '?.' , '??', '!' . Is child: Text(drinks?[index]['title']) correct and what does this question mark after drinks imply in layman language as it gets a little confusing.
@goldmenberd1350
@goldmenberd1350 3 жыл бұрын
Good feature = good practices = good code = good software = good results. Thx to devs
@hasansalim1868
@hasansalim1868 2 жыл бұрын
Thanks. Nice video as usual.
@shivambulsara8509
@shivambulsara8509 3 жыл бұрын
This is great! Thank you!
@SisirKumarPathy
@SisirKumarPathy 3 жыл бұрын
Will enabling null-safety, break existing code? Like moving from "@required" to "required" is already doing.
@sodiboo
@sodiboo 3 жыл бұрын
Yes, the type system is changing and thus code will clearly code will break, preexisting code may return "String" and return null sometimes, now that's not possible, instead you need "String?" - albeit an easy fix, but so is actually most code broken by this, even if a bit tedious to do everywhere (oh hey have you heard of that migration tool that makes it less tedious?)
@maksym.koshovyi
@maksym.koshovyi 3 жыл бұрын
C# has the same feature since C# 8, why there's no check here? 2:25 Complier analyzes code flow and warns if some value can be null where is shouldn't be
@Magnetron692
@Magnetron692 3 жыл бұрын
Thank you, much appreciated!
@NBSgamesOfficial
@NBSgamesOfficial 2 жыл бұрын
Knowing how annying NullPointerExceptions can be in Java and how NullSafety like this can be from Kotlin and Swift. I am going to love Dart even more than now... I hope it does grow out of java lol. Like. Go on. We have a Dart to javascript transcompiler. And I used it with a Cordova app a while back.
@mehmetedex
@mehmetedex 3 жыл бұрын
this is what we needed thanks
@SergeMatveenko
@SergeMatveenko 3 жыл бұрын
It worth to mention, that Rust does it in almost the same way. I was expecting to see Rust reference in the table presented in the video.
@Nephtys1
@Nephtys1 3 жыл бұрын
That's actually not correct, Rust does not have the concept of null, coming from RAII. It solves the underlying issue by using generic enums (Option and Result most of the times).
@SergeMatveenko
@SergeMatveenko 3 жыл бұрын
@@Nephtys1 Result is different. Rust does have the concept of null exactly in the way Dart has introduced it. Dart extracts null as a separated type in the type tree. Which, in effect, is the same as having a separate value for this which is None in Rust. Some in Rust or any non-Option type is the same as the default non-nullable introduced in Dart. Option in Rust has exactly the same meaning as "Type?" has now in Dart. Rust forces you to unwrap Option in the same way Dart forces you to handle null case.
@SergeMatveenko
@SergeMatveenko 3 жыл бұрын
By the way, the same behavior is in effect in modern Python using strict type annotations and a static check like mypy. Using Optional[Type] will result in the static check error unless you are handling None case successfully.
@jarnopunt
@jarnopunt 3 жыл бұрын
I really like this null safety feature, but I do not really understand why it is not possible to throw a warning (like @ 3:38 ) when you declare a function that only allows non-null variables but you send a possible null variable, like @ 4:18. This kind of feels like an 'incomplete null safety' Or am I wrong?
@abdullahhejazi6907
@abdullahhejazi6907 3 жыл бұрын
That's actually a great one. Just one question, will I be able to cast Nullable values to non-Nullable and vice versa ?
@h8moss766
@h8moss766 3 жыл бұрын
Not flutter nor affiliated with flutter, but 3:49 will probably work with variable casting too
@abdullahhejazi6907
@abdullahhejazi6907 3 жыл бұрын
@@h8moss766 oh yes, I think you're right
@PamudasanTutorial
@PamudasanTutorial 3 жыл бұрын
Hi, how do I add interstitial ads and admob banner ads to flutter ? Help me !
@arjundureja
@arjundureja 3 жыл бұрын
Similar to optionals in Swift. Nice
@TheMr82k
@TheMr82k 3 жыл бұрын
What about the existing codebase? Is null safety going to be optional? If not then will there be a official tool to help in migrating?
@ciriousjoker
@ciriousjoker 3 жыл бұрын
It's optional. Idk about a migration tool but I'd expect there will be
@filiphracek
@filiphracek 3 жыл бұрын
Yes, there is a migration tool. I'm showing it off in this part of a different video: kzbin.info/www/bejne/mGe8n6eHiLCGbck. And yes, it is also optional. You have to actively opt into the feature.
@gameplaydosabao
@gameplaydosabao 3 жыл бұрын
You guys are missing the optional cats tag (as?). This is really important when you’re writing a safe null source code.
@hardiannicko
@hardiannicko 2 жыл бұрын
It is now possible. For example: Color? color = aVariable as Color?
@agung_laksana
@agung_laksana 3 жыл бұрын
Finally, I can use it like Swift and Kotlin. When is it ready to production then?
@YolunSonu1
@YolunSonu1 3 жыл бұрын
Oh god, I developed an android app 2 years ago with older Dart version and I started to upgrade it in these days without knowing the language is almost completely changed.
@francisgeorge7639
@francisgeorge7639 3 жыл бұрын
I don't get it. I find null is a way to catch my mistakes which I think I would be more liable to miss and end up with subtle bugs, and the crashing thing, does it really happen? The ?. and ?? operators were already as much as I think we needed. Even with Delphi, 25 years ago, null exceptions were caught in the event loop and simply showed an error box, no crashing at all. And Flutter/Dart is arguably the new Delphi. C++, Java etc apps might bug out, but that was because they didn't have Anders Hejlsberg to show them the way. Can someone give me a persuasive example of how this improves our lives?
@Canaris
@Canaris 3 жыл бұрын
All the "old" null-value-errors occured at runtime. Which sucks. Now all null-value-errors occure at compile(!) time. If you program/script/tool compiles, it is guaranteed to not have any null-value-errors. That's why it's so awesome.
@francisgeorge7639
@francisgeorge7639 3 жыл бұрын
@@Canaris ahh, I get it. That is awsome.
@vinceramces
@vinceramces 3 жыл бұрын
How about the late keyword? Wasn't that part of dart's null safety feature?
@TheMr82k
@TheMr82k 3 жыл бұрын
Yeah I was waiting for that one too most of time in Flutter apps we have null due to initState, this feature also does the job but will have to add null checks everywhere
@user-v2eqj8xiz4l
@user-v2eqj8xiz4l 3 жыл бұрын
Yes, it is. new feature is ?, ! and late. you can read more here dart.dev/null-safety
@sodiboo
@sodiboo 3 жыл бұрын
Indeed. The "late" keyword works very similarly to what non-sound null safety did, it simply means "This variable should always have a value by the time it is accessed, but i can't prove that by putting it in an initializer". An example would be a "Coffee" class that has "heat()", "cool()" and "serve()" methods, in the user of this coffee library they would always either heat or cool their coffee before serving it, otherwise that's invalid - heat() and cool() each assign the "temperature" field, and before they're called that field won't have a value. Dart's type system can't know you're meant to use that method before serve(), so when accessing the temperature to decide whether to serve "ice cold", "cool", "chilly", "room temperature", "warm", "hot" or "burning" coffee dart will tell you "Hey! that value can be null". To get around this you want a bang, but if that's the intended use, just put a bang everytime, you might wanna remove the explicit bang operator, so instead the "late" keyword at variable declaration would say "Hey i can't exactly prove this to you, but just trust me that when i access this i know it won't be null unless another developer did something wrong". When a variable has the "late" modifier, the same checks will be performed as when accessing null with a bang operator (or any variable access in non-nullsafe dart), mainly because the dart type system has trust issues from several null reference errors, and when the late variable does *not* have a value (i.e. null) it throws a LateInitializationError. There is one more benefit than just removing the bang, the "late" modifier doesn't actually change the type of the variable according to what values are allowed in it, so with a nullable type and then using a bang everywhere you can assign null, with a late modifier and non-nullable type you *cannot* assign null, once it *has* a value it will *always* have a value, even if it changes if the field/variable isn't final TL;DR it's like a nullable type you can't assign null, and the dart type system will null-check it for you and throw a LateInitializationError if it's uninitialized, and it signifies it will always be assigned before usage when the type system doesn't know that.
@kazukihiromoshito2935
@kazukihiromoshito2935 3 жыл бұрын
I really am looking for some "or alternative" code that looks up to the "alternative" value if the preceding value is null or undefined, like... Color color = favoriteColor | Colors.blue; where "|" is some "or alternative" operator, such that if favoriteColor is null, it opts to the Colors.blue value. I tried it on Dart but didn't work... or are there some syntax to that? I'm rooting for a response, and if there is no operator like that yet, I hope something comes up.
@king4053
@king4053 3 жыл бұрын
Color color = favoriteColor ?? Colors.blue
@pranjal86able
@pranjal86able 3 жыл бұрын
"Stay null-safe out there", hahaha that's hilarious
@akshattamrakar9071
@akshattamrakar9071 3 жыл бұрын
Thanks
@dnnnvx
@dnnnvx 3 жыл бұрын
Awesome language, and awesome community
@arslankhan8825
@arslankhan8825 3 жыл бұрын
@Filip is java has null safety?? I don't think @2:25
@FlutterInsights
@FlutterInsights 3 жыл бұрын
I either check null value nd validate them or use null aware operator nd set the default value
@reactiveland3111
@reactiveland3111 3 жыл бұрын
common, ? mark. Wasn't it possible to use something like annotations instead?
@zakariasahri
@zakariasahri 3 жыл бұрын
Can anyone explain to me what's the difference between dart null safety and kotlin null safety??
@mrogalski
@mrogalski 2 жыл бұрын
Okay I'm just starting to learn flutter and all that dart thingy but this feels like obsessive fear of nulls. You've explained that you're not allowing "developers" ( read as pseudo developers ) to use null pointers/values just because they can hurt themselves? That's like the worst case I can think of and forcing usage of such mechanisms is wrong on it's base. Imagine having huge system that relies on some object value, let's even imagine it will be amount deducted from your client bank account and just by forcing reassignments of that value you can recieve some random number at the end of processing because "it cannot be null". This way the application instead of throwing an exception will just say "ok, we deducted this random number from you client bank account". The real question is.. when we start treating developers as adults? Or when did we become so unaware that we need that much of assistance?
@mihaelablenche
@mihaelablenche 3 жыл бұрын
Great content!
@navczydev
@navczydev 3 жыл бұрын
I am writing Kotlin day to day job, and it's also has sound null safety, when we have nullable variable we need to treat it properly otherwise compiler shows an error
@gokulakrishnan1977
@gokulakrishnan1977 3 жыл бұрын
Finally I can say goodbye for Red screen 🤩.
@Randomdude-i8x
@Randomdude-i8x 2 жыл бұрын
Instead of a null crash I now have empty screens which are harder to debug. Not sure if this is an advancement.
@nromancarcamo
@nromancarcamo 3 жыл бұрын
is this already done in Mid Feb, 2021?
@softcoda
@softcoda 3 жыл бұрын
lol...it's OK. Very good presentation
@sabuj745
@sabuj745 3 жыл бұрын
Great Video
@heinzbert3342
@heinzbert3342 3 жыл бұрын
take this feature in the compiler instead of tons of lines with questions marks
@qingbaohe7082
@qingbaohe7082 3 жыл бұрын
Can I get authorization to share to Chinese media? Such as WeChat.
@user-v2eqj8xiz4l
@user-v2eqj8xiz4l 3 жыл бұрын
This feature change everything, now all project make many errors? how deal with old project since they has many variable without question mark?
@EdgarFroes
@EdgarFroes 3 жыл бұрын
Elbow grease the heck out of that project, I say.
@redbrogdon
@redbrogdon 3 жыл бұрын
The Dart team created a tool to help you migrate your code to use null safety: dart.dev/null-safety/migration-guide. There''s still some elbow grease required, but you're not on your own!
@CollinLi
@CollinLi 3 жыл бұрын
You missed an opportunity to make that last list thingsYouDontLikeAboutNullSafety? null
@blablablabla29382
@blablablabla29382 3 жыл бұрын
sound great !! Wp
@arslankhan8825
@arslankhan8825 3 жыл бұрын
void main() { int? da=null; print('hello ${da+1 }'); } I don't understand the exact reason of null safety , above code need to apply null check. then whats the benefit ??
@yiweima4412
@yiweima4412 3 жыл бұрын
Its for handling code that is from other packages or deeply nested in the tree, when you are unsure whether the variable is null because the logic behind may not be obvious like the deliberate example above, I shall say the example is even foolish.
@arslankhan8825
@arslankhan8825 3 жыл бұрын
@@yiweima4412 you mean in this case int? da=null; "da" variable should not be the nullable. am I right?
@arslankhan8825
@arslankhan8825 3 жыл бұрын
@@yiweima4412 could you explain it as an example
@yiweima4412
@yiweima4412 3 жыл бұрын
@@arslankhan8825 First of all, you need to move away from the traditional thinking of assigning a variable null just by making it a convenient "placeholder" to accept some values later. Before declaring the variable, you need to think does the variable make sense if been given a null value (hence giving a meaningful variable name is very important here), and must have a strong enough reason to do so. For example, you are creating a social media app, and have a user model with a string field called "displayName". Your app allows user to login as a guest, hence "displayName" make sense to be nullable as guest would not have any displayName, then it makes sense to declare it as sound null safe: String? displayName; When accessing the variable, it thus make sense also to check whether the variable is null before using it: print(displayName);
@arslankhan8825
@arslankhan8825 3 жыл бұрын
@@yiweima4412 Thank you so much for a great detail, I will read it let you know if have any question. again Thank you so much
@mileusna
@mileusna 3 жыл бұрын
What about initial values? int count; Is count still null or 0? Will this be allowed without question mark?
@redbrogdon
@redbrogdon 3 жыл бұрын
Non-nullable fields are required to be initialized with values, though you can mark them "late" in the rare case that you aren't able to initialize them right away (but will before they're read).
@filiphracek
@filiphracek 3 жыл бұрын
Also, thanks to flow analysis, you can do something like this: int count; if (blah) { count = 10; } else { count = 0; } // ... Here, `count` is _non-nullable_, even though it starts uninitialized. Dart proves the count is not read before it is assigned, and allows this. Note that this only works for local variables (e.g. in functions). For class fields, Dart can't prove things like that, so you need something like `late`.
@mileusna
@mileusna 3 жыл бұрын
@@filiphracek Thanks. Since I do go-lang on server side I was secretly hoping it would be similar like in the Go where by default int is 0, string is "" etc. 😁 It will be interesting migration. 😁
@GeorgeNoiseless
@GeorgeNoiseless 2 жыл бұрын
Indeed. Stay null-safe, everyone!
@kapowrobot7942
@kapowrobot7942 3 жыл бұрын
Also the larger general programming question is.... Is null a feature or bug?
@yiweima4412
@yiweima4412 3 жыл бұрын
I shall say both, its a bug if you dont use this feature correctly.
@iitgsahil
@iitgsahil Жыл бұрын
Please fix the subtitles 🙏 They're lagging
@ludanaltegani5654
@ludanaltegani5654 2 жыл бұрын
Thank you
@erlangparasu6339
@erlangparasu6339 3 жыл бұрын
why kotlin is not 'sound null safety' ?
@filiphracek
@filiphracek 3 жыл бұрын
Here's an analysis of Kotlin and other languages: github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/roadmap.md#kotlin
@asadsalehumar1011
@asadsalehumar1011 3 жыл бұрын
I really don't understand the meaning of 'sound'. What does it mean? As a non native speaker, I only understand 'sound' as in 'sound wave' which we hear.
@filiphracek
@filiphracek 3 жыл бұрын
The word sound has a bunch of unrelated meanings. One of them is "dependable" or "reliable". In the context of null safety or type systems, it means the system is not approximating. It can _prove_ things are one way or another.
@davidchopin6583
@davidchopin6583 3 жыл бұрын
Any guard let/if let?
@pkgo1122
@pkgo1122 9 ай бұрын
Awesome! 🚀
@kevinliu6002
@kevinliu6002 3 жыл бұрын
Stress syllable on the first syllable for va-ri-a-ble, sir! VA-riable. Not va-RIA-ble.
@edwardduong6914
@edwardduong6914 3 жыл бұрын
This is not null safety, this is just a way to declare a maybe-null-variable.
@1995taunus
@1995taunus 3 жыл бұрын
Thank you!
@lasindunuwanga5292
@lasindunuwanga5292 3 жыл бұрын
Great vid
@casul-4891
@casul-4891 3 жыл бұрын
Safety can be fun !
Introducing Widget of the Week!
0:56
Flutter
Рет қаралды 530 М.
Async vs Isolates | Decoding Flutter
4:24
Flutter
Рет қаралды 126 М.
How to whistle ?? 😱😱
00:31
Tibo InShape
Рет қаралды 16 МЛН
DID A VAMPIRE BECOME A DOG FOR A HUMAN? 😳😳😳
00:56
Сюрприз для Златы на день рождения
00:10
Victoria Portfolio
Рет қаралды 2,4 МЛН
👨🏽‍💻 Dart Null Safety (Simple)
14:24
Mitch Koko
Рет қаралды 12 М.
Why null safety? | Session
15:14
Flutter
Рет қаралды 38 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 477 М.
Generative AI in a Nutshell - how to survive and thrive in the age of AI
17:57
Dear Game Developers, Stop Messing This Up!
22:19
Jonas Tyroller
Рет қаралды 721 М.
I reverse engineered Next to find what they are hiding
29:48
Theo - t3․gg
Рет қаралды 10 М.
Dart Streams - Flutter in Focus
8:01
Flutter
Рет қаралды 259 М.
why do void* pointers even exist?
8:17
Low Level
Рет қаралды 375 М.
Think Faster, Talk Smarter with Matt Abrahams
44:11
Stanford Alumni
Рет қаралды 1,7 МЛН
How to whistle ?? 😱😱
00:31
Tibo InShape
Рет қаралды 16 МЛН