Good info, but also good to remember how messy this can make your code if you rely on it to 'simplify code'. Unless you're working with an annoying API you should always declare types as specific as possible because relying on type promotion is evidently dodgy
@EdouardTavinor2 жыл бұрын
I'd say that a nullable type in dart or kotlin is like an option in scala or an optional in java. There's certainly a use-case for these types. This null check and type promotion is rather like a foreach in scala or Haskell.
@francisgeorge76392 жыл бұрын
tldr, dart can't predict the result through a getter as it could be overriden, so type promotion through a getter doesn't work without first setting to a local variable.
@daviduribe42 жыл бұрын
Not only overridden, their values could also change whenever they’re accessed!
@francisgeorge76392 жыл бұрын
@@daviduribe4 of course, forgot that though it did occur to me momentarily. Indeed that's the real reason.
@rethinabair7344 Жыл бұрын
@@francisgeorge7639 guys correct me if I'm wrong but this code works fine class Animal { String get sound => 'Unknown sound'; } class Dog extends Animal { @override String get sound => 'Woof!'; } void main() { Animal animal = Dog(); if (animal is Dog) { print(animal.sound.toUpperCase()); } }
@vivekkumar-nb3sw2 жыл бұрын
Thank you so much for Hindi subtitles.......it is really useful info for us...and i am expecting hindi subtitles for all the videos of this channel......thank you so much....love u guyz
@flutterdev2 жыл бұрын
Thank you for the wonderful feedback, Vivek! We're glad to have you in the Flutter community 🙂
@thomasmabika72912 жыл бұрын
Excellent explanation! More intermediate to advance concepts please.
@flutterdev2 жыл бұрын
We're delighted that you have enjoyed the video, Thomas. Keep an eye out for more videos coming your way!
@LoneWolf-hg2ix2 жыл бұрын
"Nullable types are a union type of null and its underlying type..." Wouldn't that mean that technically union types already exist understood in dart? Probably in the nearest future we see it as a native language feature?
@renotanumber2 жыл бұрын
FutureOr is also union type (may be older than non nullability?). Now imagine: FutureOr? is a union of: T, Future and null.
@Raimkhodzhanov2 жыл бұрын
Thank You, it was very useful!
@hussainkhuzema70832 жыл бұрын
Truly awesome
@youssef.elmoumen2 жыл бұрын
I like the way she's spelling shtring Great explanation 💞
@farahrayis59282 жыл бұрын
She's sweet
@youssef.elmoumen2 жыл бұрын
@@farahrayis5928 Yes 🌸
@cermilbonzo2 жыл бұрын
What color theme & font of your editor?
@vatsaltanna51992 жыл бұрын
Thanks for the video 🎉
@RobFearn2 жыл бұрын
Nice explanation thank you!
@flutterdev2 жыл бұрын
You're truly welcome, Rob. We're glad to have you a part of the Flutter community 👍
@ajaykotiyal427Ай бұрын
sealed classes are now introduced in Dart 3.x
@Tech1st2 жыл бұрын
Can i use var?
@TungNguyen-lt5ej2 жыл бұрын
From Viet Nam with lov3!
@aytunch2 жыл бұрын
PERFECT!
@HuntingKingYT2 жыл бұрын
Heads up to Khanh Never gonna give you up! Nguyen
@hideokuwaki2 жыл бұрын
This was great content!
@flutterdev2 жыл бұрын
Thanks for the love, Hideo! We truly appreciate hearing what community members think about our content 🙌 If you enjoyed this, don't forget to check out more Decoding Flutter here: goo.gle/DecodingFlutter
@bennguyen13132 жыл бұрын
How does the variable-type followed by a question-mark work? for example when do you want to assign a null via "String?" "int?" vs "late var"?
@andrewbrogdon5582 жыл бұрын
A type declaration like `int?` just means you're declaring a variable that can hold either an int value or null, in contrast to `int`, which *must* hold an int value at all times. The `late` keyword allows you to cheat a bit, essentially. If you declare a `late int`, you're telling the compiler three things: 1) You want a variable that must hold an int value, 2) you're not actually going to *give* it a value right away, but 3) you promise to stick a value in it before any code attempts to access that variable and use its value. So, you get some of the benefits of using a non-nullable variable (fewer null checks later in your code, for example), but you're also taking responsibility for making sure you assign a value to that variable before your app ever needs to read the value out.
@normi60462 жыл бұрын
Thanks!!
@flutterdev2 жыл бұрын
Glad you enjoyed the video! Be sure to check out more episodes of Decoding Flutter here: goo.gle/DecodingFlutter Happy Fluttering 😎
@kprakash96652 жыл бұрын
Can we Build an Ecommerce Application by using Flutter Madam
@nafeewalee2 жыл бұрын
Objection hearsay!
@materialapp2 жыл бұрын
Compound, no foundation
@rylaczero37402 жыл бұрын
Well, gonna wait for sealed classes.
@dharmasumansinghddharmasum81042 жыл бұрын
Good infoso very good
@flutterdev2 жыл бұрын
Happy to hear that the information provided was helpful! You can also check out the DartPad for this lesson here: goo.gle/3zcEobW Have a Fluttertastic day ahead 😁
@mibi20072 жыл бұрын
That's why I want to forget all of these check and go with functional programming for data and application layer in Flutter app :)
@chouhanrahul2 жыл бұрын
😍
@vinceramces2 жыл бұрын
type promotion should also infer type without needing to do nested if statement. For example, if(x != null) return x.copyWith(...)
@philohan952 жыл бұрын
Please give Dart an `if let` functionality like Swift.
@fredgotpub8712 жыл бұрын
Pay attention, rickRoll towards the end.
@dikatok2 жыл бұрын
objection your honor, rofl
@fille.imgnry2 жыл бұрын
IT WAS NULL!! 😂
@AiDidthis.2 жыл бұрын
😂 I thought there was a data type called Promotion
@nicktech21522 жыл бұрын
C# solves this in a more elegant way: if(maybeString is string stringForSure){ // do actions with stringForSure inlinly declared variable }
@efliedus12672 жыл бұрын
Literally 6 minutes on thing that must be avoided as much as possible in strict typed programming languages... But yeah for niche cases that knowledge is indeed useful