Dart GETTER and SETTER | Private Instance variables. Dart Programming for Flutter #9.1

  Рет қаралды 80,017

Smartherd

Smartherd

Күн бұрын

Пікірлер: 68
@shubhamdubey1996
@shubhamdubey1996 6 жыл бұрын
I'm following this whole Dart tutorial Series from the beginning and You're a good teacher (No Doubt). I also want you to add some extra information like why we need this particular thing? For example In this video you taught 'How to use Getter and Setter' but What you missed is Why we need to use Getter and Setter while we can assign the values directly. Yes! We can google it, But these extra information that is also with real life example will make your videos/lectures Stand Out. Thank you for Such informative and easily understandable videos :)
@smartherd
@smartherd 6 жыл бұрын
noted. such feedback really helps thanks
@thegreenboxindia3579
@thegreenboxindia3579 4 жыл бұрын
@@smartherd Actually even i would roco that, you teach well at a steady pace, just the above point might help you more. Even i googled a lot of stuff on y, how i got it from u. But good work.
@se7en2021
@se7en2021 4 жыл бұрын
Exactly i was thinking the same, why should we use ???
@tevinmorake8924
@tevinmorake8924 4 жыл бұрын
Well done! I think everyone here can agree that you deserve more recognition for the awesome tutorial series you've given us. Thanks
@smartherd
@smartherd 4 жыл бұрын
Thanks man :: Also, check out my personal KZbin Vlog channel: bit.ly/sriyank-vlog
@denizgur
@denizgur 4 жыл бұрын
OK this video was much better than the Dart tutorial I've purchased. Now I understand getters and setters. Thank you.
@dennisrodriguez9202
@dennisrodriguez9202 4 жыл бұрын
Thanks bro my native language isn't English but I came here cuz I was watching a Spanish video and I had understood nothing, but ur video yas! love u!
@leandroacevedo3339
@leandroacevedo3339 4 жыл бұрын
Same thing happened to me! irónico, no?
@marufhassan634
@marufhassan634 2 жыл бұрын
How your channel still doesn't have a million subscriber is beyond my understanding.
@vinimaykaul
@vinimaykaul 5 жыл бұрын
By far the most explanatory video tutorial series. Excellent Job Guys.
@LearnWithYK
@LearnWithYK 2 жыл бұрын
Thanks and Congratulations for creating this wonderful series. You are, no doubt, an excellent teacher.
@Nepermath
@Nepermath 6 жыл бұрын
First of all I already subscribed to your very good channel. to solve the division problem (marksecured ~ / 500) * 100 without having to change the type of variable to Double, simply change the order of execution of the calculation to (marksecured * 100) ~ / 500
@md.soleymankhan6550
@md.soleymankhan6550 4 жыл бұрын
Best dart tutorial ever.
@taiwo763
@taiwo763 4 жыл бұрын
i had to subscribe cos of this tutorial. For the first time, it actually made sense
@香烤麻糬球
@香烤麻糬球 5 жыл бұрын
In best practice: 1. It should be `set int someField`, not `void set int someField`. 2. You should not create a field to change another field, in your case `percentage -> percent`.
@TheRizse
@TheRizse 5 жыл бұрын
Hi sir, can you kindly help me explain the point no 2 that you mention. What is creating another field to change another field?
@香烤麻糬球
@香烤麻糬球 5 жыл бұрын
​@@TheRizse The idea is that every field has built-in getter & setter, so no need to recreate the wheel. From official docs: dart.dev/guides/language/effective-dart/usage#dont-wrap-a-field-in-a-getter-and-setter-unnecessarily See also: [Language Tour - Methods - Getters and setters]: dart.dev/guides/language/language-tour#methods
@attimeequalszero6750
@attimeequalszero6750 4 жыл бұрын
@@TheRizse dart.dev/guides/language/effective-dart/usage#avoid-storing-what-you-can-calculate
@ishaqkhan4508
@ishaqkhan4508 4 жыл бұрын
bro you should make a seperate video for why we need getter and setter?thanks for ur efforts though
@noelxxiv9382
@noelxxiv9382 4 жыл бұрын
Exactly, i think it is used to do a computation of percentage in this case. as constructors cannot return any values. **This is my real lay understanding . First language I m learning is dart.
@ranya6266
@ranya6266 2 жыл бұрын
Thank you so much for making it sooooo EASY really appreciate your efforts :)
@mohamednizam5298
@mohamednizam5298 4 жыл бұрын
A very good tut on dart as an intro to flutter . just further clarification on getter and setter as to the actual use of it. Still cant understand its purpose. thanks again on this tut.
@iplayguitar1000
@iplayguitar1000 3 жыл бұрын
Thanks man. Better than the docs.
@dexterousdivya
@dexterousdivya 9 ай бұрын
Here is the latest code for Dart 3 // OBJECTIVES // 1. Default Getter and Setter // 2. Custom Getter and Setter // 3. Private Instance Variable void main() { var s1 = Student(); s1.name = "Peter"; // Calling default Setter to set value print(s1.name); // Calling defailt Getter to get value s1.percentage = 438.0; // Calling Custom Setter to set value print(s1.percentage); //Calling Custom Getter to get value } class Student { String? name; // Instance variable with default getter and setter late double _percent; // Private Instance variable for its own library // Instance variable with Custom Setter void set percentage(double marksSecured) => _percent = (marksSecured / 500) * 100; // Instance variable with Custom Getter double get percentage => _percent; }
@thevoidyouseek
@thevoidyouseek 7 ай бұрын
thank you
@masrursakib6528
@masrursakib6528 4 жыл бұрын
Awesome video, helped me with what I was looking for.
@whitehawk4671
@whitehawk4671 2 жыл бұрын
in case you forgot how to write getter and setter, go to Code(only for intellij) and the click on generate, to generate getter and setter you can also use alt+insert to get it directly....
@user-or7ji5hv8y
@user-or7ji5hv8y 3 жыл бұрын
always very well explained
@mizanur_sajid
@mizanur_sajid 3 жыл бұрын
- 2:28 if you face any error with the (String name) then just make it like this >> (String? name)
@kishansindhi6963
@kishansindhi6963 3 жыл бұрын
What about double get percentage => return percent; can you please help me with it?
@keithbacalso9433
@keithbacalso9433 3 жыл бұрын
awsome tutorial keep it up!
@adamtak3128
@adamtak3128 5 жыл бұрын
You explained the syntax but not what getters and setters are for. What's the purpose or having private variables and setter/getter? Can't that exact thing just be done with a method instead?
@md.soleymankhan6550
@md.soleymankhan6550 4 жыл бұрын
You will get the point during firebase anon authentication.
@FlutterShipp
@FlutterShipp 2 жыл бұрын
Great video
@muhammadjunaid3684
@muhammadjunaid3684 2 жыл бұрын
Well, I have a question. If setters can alter the members/fields of a class. Then why do we use setters in the first place instead of regular (public) fields. Because, in both scenarios we can change/modify the fields and we are losing control over the data. Aren't we?? Thanks in advance.
@QUniversity
@QUniversity 4 жыл бұрын
Great explanation.
@shrikantakalantri1787
@shrikantakalantri1787 3 жыл бұрын
nice explanation
@mockingbird3809
@mockingbird3809 5 жыл бұрын
Thank you so much for this amazing video
@jajasaria
@jajasaria 5 жыл бұрын
love your videos. May i know where did you get the reference of all of your lesson? I like the objectives part, you nailed the difference of each type.
@4funrc11
@4funrc11 5 жыл бұрын
Lost in trying to determine which exact video that is supposedly linked to using => (fat arrow) in this video's description.
@mainulhoque8816
@mainulhoque8816 4 жыл бұрын
4FunRC here you go - kzbin.info/www/bejne/fGWVmoCMlrN0gqM
@tGoldenPhoenix
@tGoldenPhoenix 3 ай бұрын
Thank you!
@rahulmullick7316
@rahulmullick7316 4 жыл бұрын
sir mein bahat baar pada hu yea privet public protected but mujhe yea samajh abhi tak nehi aya why these are came into action...cause every local variable have not accessed out side function or class...then why....????
@TouhidSunny
@TouhidSunny 4 жыл бұрын
your example is like a stateless widget. but in flutter if i use stateful widget then i cant access the percentage method from main. if i declare it in widget then ok. but in state i cant access it. please tell me the reason.
@pratik1853
@pratik1853 2 жыл бұрын
use late keyword before such as late String name; to print in new dartpad
@pratik1853
@pratik1853 2 жыл бұрын
or assign values such as String name='abc';
@voodoo7183
@voodoo7183 5 жыл бұрын
Avoid the use of return types in setters such as in your example "void set percentage"
@pratyakshpandey2248
@pratyakshpandey2248 3 жыл бұрын
Just want to ask what is difference between getter, setter and constructor? I mean, we could have just made a function percentage of datatype double and then directly return the value of percentage. So, I want to know the real difference between getter, setter and dart!
@NikhilSharma-wx7kb
@NikhilSharma-wx7kb 2 жыл бұрын
I was wondering the same thing.
@z-medianetwork408
@z-medianetwork408 6 жыл бұрын
I made an app in android studio. When I run on real device from pc, it installs apk & run well with splash screen. But when I run it again from the real device icon, it doesn't show the splash screen but displays white screen. Why? Please help. Thanks.
@noelxxiv9382
@noelxxiv9382 4 жыл бұрын
Can anyone explain what is the difference between a constructor and getter/setter?
@DholaSain
@DholaSain 2 жыл бұрын
thanks bro
@pawan2647
@pawan2647 5 жыл бұрын
bro cant we use normal functions to get and set the value, plus arent there any concept of private data members which are private to the class only.
@syntaxerror1044
@syntaxerror1044 5 жыл бұрын
Hello...While trying to understand Getter and Setter, I stumbled upon this piece of code from an article from 2012. I pasted the same code into my editor but it gave me error and i was wondering if this code is using old syntax as it is from 2012. Anyone?? void main() { var obj = new GetnSetMet(); obj.firstName="Google"; obj.lastName="Dart!"; print(obj.FullName); } class GetnSetMet{ String f_name,l_name; String get firstName() => f_name; set firstName(String value) => f_name = value; String get lastName() => l_name; set lastName(String value) => l_name = value; String get FullName() => firstName.concat(lastName); }
@ahmdmnsor
@ahmdmnsor 4 жыл бұрын
what is the library it will be private to ?
@unknown.breakdown
@unknown.breakdown 5 жыл бұрын
I don't like fat arrow syntax. It saves a few lines of code, but looses readability.
@zuhaib4030
@zuhaib4030 4 жыл бұрын
plz help me its isnt working trying tooo hard but its isn t can you help me out
@SagarSagar-ro3fj
@SagarSagar-ro3fj 5 жыл бұрын
If there is no private then y getter setters are used .?
@noreplay6418
@noreplay6418 4 жыл бұрын
why i get this warning when i try to create a getter and setter for private variable Avoid wrapping fields in getters and setters just to be "safe".
@leandroacevedo3339
@leandroacevedo3339 3 жыл бұрын
Bravo
@atefehmohammadpoor9177
@atefehmohammadpoor9177 4 жыл бұрын
thannnnks
@shumailasami6765
@shumailasami6765 6 жыл бұрын
what about method overloading?
@smartherd
@smartherd 6 жыл бұрын
In dart, method overloading not allowed
@snapshuttre
@snapshuttre Жыл бұрын
i am getting errors one after another. I guess I am in the new version dart. I have came here by completing all the previous videos before of this course, but this made me sad, your course is not completely valid with the latest dart sdks.
@suleman4183
@suleman4183 5 жыл бұрын
You putting great effort, but beginner just cannot understand these tutorials you're using too much jargon and you're not explaining enough a why certain thing do this or do that.
@mahmudizukri
@mahmudizukri 4 жыл бұрын
Subtitle please
@mashakozlova9425
@mashakozlova9425 4 жыл бұрын
"methods" man "methods". not "methord" and why do you talk about yourself as "we"?
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Getters and Setters Java Tutorial #84
14:12
Alex Lee
Рет қаралды 512 М.
Bringing pattern matching to Dart
20:28
Flutter
Рет қаралды 39 М.
Dart Futures - Flutter in Focus
8:55
Flutter
Рет қаралды 203 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
THIS Is How You Should Be Making Getters & Setters In Python
7:32
Getter and Setter In Dart - Learn Dart Programming
15:33
Dart Tutorial
Рет қаралды 2,9 М.
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 93 М.