Type Promotion | Decoding Flutter

  Рет қаралды 24,792

Flutter

Flutter

Күн бұрын

Пікірлер: 51
@merthyr1831
@merthyr1831 2 жыл бұрын
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
@EdouardTavinor
@EdouardTavinor 2 жыл бұрын
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.
@francisgeorge7639
@francisgeorge7639 2 жыл бұрын
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.
@daviduribe4
@daviduribe4 2 жыл бұрын
Not only overridden, their values could also change whenever they’re accessed!
@francisgeorge7639
@francisgeorge7639 2 жыл бұрын
@@daviduribe4 of course, forgot that though it did occur to me momentarily. Indeed that's the real reason.
@rethinabair7344
@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-nb3sw
@vivekkumar-nb3sw 2 жыл бұрын
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
@flutterdev
@flutterdev 2 жыл бұрын
Thank you for the wonderful feedback, Vivek! We're glad to have you in the Flutter community 🙂
@thomasmabika7291
@thomasmabika7291 2 жыл бұрын
Excellent explanation! More intermediate to advance concepts please.
@flutterdev
@flutterdev 2 жыл бұрын
We're delighted that you have enjoyed the video, Thomas. Keep an eye out for more videos coming your way!
@LoneWolf-hg2ix
@LoneWolf-hg2ix 2 жыл бұрын
"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?
@renotanumber
@renotanumber 2 жыл бұрын
FutureOr is also union type (may be older than non nullability?). Now imagine: FutureOr? is a union of: T, Future and null.
@Raimkhodzhanov
@Raimkhodzhanov 2 жыл бұрын
Thank You, it was very useful!
@hussainkhuzema7083
@hussainkhuzema7083 2 жыл бұрын
Truly awesome
@youssef.elmoumen
@youssef.elmoumen 2 жыл бұрын
I like the way she's spelling shtring Great explanation 💞
@farahrayis5928
@farahrayis5928 2 жыл бұрын
She's sweet
@youssef.elmoumen
@youssef.elmoumen 2 жыл бұрын
@@farahrayis5928 Yes 🌸
@cermilbonzo
@cermilbonzo 2 жыл бұрын
What color theme & font of your editor?
@vatsaltanna5199
@vatsaltanna5199 2 жыл бұрын
Thanks for the video 🎉
@RobFearn
@RobFearn 2 жыл бұрын
Nice explanation thank you!
@flutterdev
@flutterdev 2 жыл бұрын
You're truly welcome, Rob. We're glad to have you a part of the Flutter community 👍
@ajaykotiyal427
@ajaykotiyal427 Ай бұрын
sealed classes are now introduced in Dart 3.x
@Tech1st
@Tech1st 2 жыл бұрын
Can i use var?
@TungNguyen-lt5ej
@TungNguyen-lt5ej 2 жыл бұрын
From Viet Nam with lov3!
@aytunch
@aytunch 2 жыл бұрын
PERFECT!
@HuntingKingYT
@HuntingKingYT 2 жыл бұрын
Heads up to Khanh Never gonna give you up! Nguyen
@hideokuwaki
@hideokuwaki 2 жыл бұрын
This was great content!
@flutterdev
@flutterdev 2 жыл бұрын
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
@bennguyen1313
@bennguyen1313 2 жыл бұрын
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"?
@andrewbrogdon558
@andrewbrogdon558 2 жыл бұрын
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.
@normi6046
@normi6046 2 жыл бұрын
Thanks!!
@flutterdev
@flutterdev 2 жыл бұрын
Glad you enjoyed the video! Be sure to check out more episodes of Decoding Flutter here: goo.gle/DecodingFlutter Happy Fluttering 😎
@kprakash9665
@kprakash9665 2 жыл бұрын
Can we Build an Ecommerce Application by using Flutter Madam
@nafeewalee
@nafeewalee 2 жыл бұрын
Objection hearsay!
@materialapp
@materialapp 2 жыл бұрын
Compound, no foundation
@rylaczero3740
@rylaczero3740 2 жыл бұрын
Well, gonna wait for sealed classes.
@dharmasumansinghddharmasum8104
@dharmasumansinghddharmasum8104 2 жыл бұрын
Good infoso very good
@flutterdev
@flutterdev 2 жыл бұрын
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 😁
@mibi2007
@mibi2007 2 жыл бұрын
That's why I want to forget all of these check and go with functional programming for data and application layer in Flutter app :)
@chouhanrahul
@chouhanrahul 2 жыл бұрын
😍
@vinceramces
@vinceramces 2 жыл бұрын
type promotion should also infer type without needing to do nested if statement. For example, if(x != null) return x.copyWith(...)
@philohan95
@philohan95 2 жыл бұрын
Please give Dart an `if let` functionality like Swift.
@fredgotpub871
@fredgotpub871 2 жыл бұрын
Pay attention, rickRoll towards the end.
@dikatok
@dikatok 2 жыл бұрын
objection your honor, rofl
@fille.imgnry
@fille.imgnry 2 жыл бұрын
IT WAS NULL!! 😂
@AiDidthis.
@AiDidthis. 2 жыл бұрын
😂 I thought there was a data type called Promotion
@nicktech2152
@nicktech2152 2 жыл бұрын
C# solves this in a more elegant way: if(maybeString is string stringForSure){ // do actions with stringForSure inlinly declared variable }
@efliedus1267
@efliedus1267 2 жыл бұрын
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
@g0rbachov
@g0rbachov Жыл бұрын
Straeng
@joranmulderij
@joranmulderij 2 жыл бұрын
28 views 9 likes? WOW!!
ThemeExtensions | Decoding Flutter
6:13
Flutter
Рет қаралды 59 М.
Intrinsic widgets | Decoding Flutter
8:11
Flutter
Рет қаралды 50 М.
УЛИЧНЫЕ МУЗЫКАНТЫ В СОЧИ 🤘🏻
0:33
РОК ЗАВОД
Рет қаралды 7 МЛН
Async vs Isolates | Decoding Flutter
4:24
Flutter
Рет қаралды 131 М.
Unbounded height / width | Decoding Flutter
4:54
Flutter
Рет қаралды 147 М.
GestureArena | Decoding Flutter
8:30
Flutter
Рет қаралды 39 М.
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 199 М.
Synchronous BuildContexts | Decoding Flutter
6:15
Flutter
Рет қаралды 47 М.
A Deep Dive into JVM Start-Up
22:03
Java
Рет қаралды 30 М.
Top 30 Flutter Tips and Tricks
6:50
Flutter Mapp
Рет қаралды 583 М.
5 Secrets to Stop Stuttering & Speak More Clearly!
12:44
Vinh Giang
Рет қаралды 117 М.
ShrinkWrap vs Slivers | Decoding Flutter
4:31
Flutter
Рет қаралды 131 М.