Тёмный

Dart Constructors in Inheritance: Default and Named Constructors. Dart for Flutter #9.5 

Smartherd
Подписаться 136 тыс.
Просмотров 48 тыс.
50% 1

Access 7000+ courses for 15 days FREE: pluralsight.px...
Dart for Flutter. Explore how to use Constructors both Default and Named during Inheritance. See how to call Super / Parent class constructor from the sub/child class using super keyword and also explore how to pass values to the super class constructors from the child class constructor. Along with all these, check out how to deal with Named, no-argument or parameterised constructors during Inheritance.
Next Video : • Dart Abstract Class an...
Previous Video : • Dart Method Overriding...
Code Files: bit.ly/2S6JPBw .
.
Please donate and support my work
(If you think my free tutorials are better than paid ones :)
- Patreon: bit.ly/patreon...
- Paypal/Payoneer: sriyank123@gmail.com
- UPI (only for India): smartherd@okaxis
:: If you want to develop a website or a mobile app, email me your requirement at sriyank.siddhartha@gmail.com :: Free demos provided beforehand ::
- Access my premium courses: bit.ly/sriyank...
Free Programming courses:
- Ruby Programming: bit.ly/smyt-r
- Dart Programming: bit.ly/smyt-d
- Kotlin Programming: bit.ly/smyt-k
- Java Programming: bit.ly/smyt-j
- Kotlin Coroutines: bit.ly/smyt-coru
Free Flutter course:
- Flutter App Development: bit.ly/2Rg7EFR
Free Android courses:
- Android using Kotlin: bit.ly/smyt-ka
- Android using Java: bit.ly/smyt-ja
- Android Material Design: bit.ly/2SMJqU6
- Android Jetpack Architecture: bit.ly/yt-j
- Android Multiple Screen Support: bit.ly/smyt-mss
- Android Retrofit: bit.ly/2Ee6GHn
More free programming courses:
- bit.ly/smy-list
Check out my website:
- bit.ly/smartherd
Let's get in touch! [Sriyank Siddhartha]
LinkedIn: bit.ly/sriyank...
Facebook: bit.ly/smarthe...
Instagram: bit.ly/sriyank...
Twitter: bit.ly/sriyank...
Github: bit.ly/smarthe...
--- Thank you for your love and support ---

Опубликовано:

 

18 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 66   
@itsumairsyed
@itsumairsyed 2 года назад
Surely, these tutorials feel like a breeze in the hot summer. Beautifully explained object oriented programming concepts. Every now and then I am stuck with entangling concepts in Flutter, I come back to this series. Thanks a lot for your work!!
@limei5414
@limei5414 4 года назад
Good tutorial!I don’t know why someone say they don’t understand what you say I think it’s very clear to understand,Thank you!
@deepusingla6882
@deepusingla6882 4 года назад
Because they are coming from direct c to dart 😂😂😂😂
@jangeisler6961
@jangeisler6961 4 года назад
Best ever Dart tutorials :) Great job! Although in this one particular video, I dislike the part, where you make a lot of changes to "breed" and "color" and playing with their inheritances , while your output (print) says the same thing every time you compile / run. It makes it a bit hard for beginners like me to see, what actually changed when you run your code. But that's just a small thing, overall THANKS and GREAT JOB
@BotanAbdullah
@BotanAbdullah 5 лет назад
By far the best tutorial about Dart on RU-vid.
@smartherd
@smartherd 5 лет назад
thanks alot
@thiruvenkatasamypranesh80
@thiruvenkatasamypranesh80 6 месяцев назад
@@smartherd
@anirudhachakrabarty2050
@anirudhachakrabarty2050 4 года назад
Best tutorial... At first I get confused then I watched again.. It is really easy... Thank you for the tutorial.. This will help me while coding in flutter..
@leandroacevedo3339
@leandroacevedo3339 4 года назад
I still don't see how to apply these things in real life... I wish you put more practical examples
@fclinuxnova7977
@fclinuxnova7977 4 года назад
this is super crazy video content to the newbie, I wish to do the same in my small project ... :D
@ishaqkhan4508
@ishaqkhan4508 4 года назад
AWESOME VIDEO.TO THOSE WHO DIDNT GET IT YOU SHOULD PRACTICE THESE ATLEAST FOR ONE WHOLE DAY
@ozgurozdemir8224
@ozgurozdemir8224 2 года назад
Thank you for this clean lesson.
@smartherd
@smartherd 2 года назад
Namaste
@peekpt
@peekpt 6 лет назад
Nice work following this tutorial everyday!
@user-or7ji5hv8y
@user-or7ji5hv8y 5 лет назад
Very clear explanation
@pranavpatil.7
@pranavpatil.7 5 лет назад
Whats the use of passing so many parameters but not displaying them or showing them in the output window? If you put one simple statement of: print("${this.breed} and ${this.color}"); then we can understand it easily..! great tutorial btw!
5 лет назад
I've understood nothing :(
@yakine13
@yakine13 4 года назад
Indeed this video has been confusing for many person because there's no change in output. everyone make mistake :p next time, be sure to always make change so that we can follow what the code is doing.
@muhammadyusoffjamaluddin
@muhammadyusoffjamaluddin 4 года назад
From start to 5:55 I dont understand any of it. same output but you placed so many variable inside, too much like Labador, Black, Pug and Brown but none even one being output there, not even explain what is happening. Did not explain anything why got that. I think this is the worst/confusing one I have seen in your series, others are explained 'perfect', not this one.
@indiancodingclub
@indiancodingclub 5 лет назад
sir plzz make more vedios on flutter or dart your vedios are great
@vighneshsharma
@vighneshsharma 2 года назад
Why cant i use super class variable with child class here's the code below void main(){ var dog1 = Dog("lab","brown"); dog1.age = 12; print(""); var dog2 = Dog("pug", "black"); dog2.age = 10; print(""); } class Animal{ var age; Animal(){ print("Animal class constructor"); } } class Dog extends Animal{ Dog(var breed, var color) : super(){ print("dog class constructor"); print("$breed and $color and ${super.age}"); } } Getting null in the OUTPUT please help , i want to use variable from super class itself why is it not happening??
@mateusvenancio
@mateusvenancio 2 года назад
Great video thank you!
@righteous-wend
@righteous-wend 5 лет назад
I tried to donate this channel in paterion but the problem is paterion ask me to donate the channel every month, where I can't. I would like to donate the channel with 50$ but for one time. Could somebody help me out with this?
@smartherd
@smartherd 5 лет назад
Hi Faisal, you can donate one time via paypal or payoneer at "sriyank123@gmail.com". If you are in India, you can donate via UPI at "smartherd@okaxis" . OR there is one more option, you can pledge 50$ at patreon and once the money is deducted from your account, you can cancel your pledge after first deduction. Let me know if any of these works. and very very thank you for your support.
@Nicosfrs
@Nicosfrs 2 года назад
Encapsulation says you should use private attributes, but this brought me an issue. I cannot access super-class attributes in my sub-class. I've readed that if classes are in different files, you cannot read them if their private, so should I just use public attributes or use multiple classes in the same file? which of this fixes are commonly accepted/not considered a bad practice?
@savedbygrace.slowedreverb
@savedbygrace.slowedreverb 2 года назад
It doesn't look like the super constructor is working here, the output has been staying that same. Not sure why. Any fixes?
@anoundhim4393
@anoundhim4393 5 лет назад
please create constuctor overiding with parameters and it's possible for use optional parameters? please give example
@karthickrajalearn
@karthickrajalearn 5 лет назад
In 2m 02sec Thanks for Introducing In 4m 01sec In 4m 43sec
@rajdhakad7380
@rajdhakad7380 5 лет назад
Bro what if I ONLY want to call child class constructor when an object of the child class is created?
@perfectlyflawwwwed
@perfectlyflawwwwed 5 лет назад
wouldn't you just have to make sure there is either always a bogus default value or just make sure that your parent class doesn't have parameters.
@siddhantpalde2025
@siddhantpalde2025 4 года назад
how can i call default Animal constructor and Animal named constructor from child dog default / named constructor plzzzz help..
@arshadsaid3154
@arshadsaid3154 Год назад
Wow it actually looks like java but shorter😮
@realityandtruth9662
@realityandtruth9662 3 года назад
hello sir please help me.. Is flutter app size too big ? it is rumour or true sir...
@krishnakumarramachandran5888
@krishnakumarramachandran5888 5 лет назад
Super Sir.
@Allen-ih1fc
@Allen-ih1fc 5 лет назад
Good job! Bro
5 лет назад
İf you don't use this.color in Dog class and call the dog2.color, it shows "Black" but if you use it shows "Brown". ".this usage" is always confusing my mind. I mean: class Dog extends Animal{ String breed; Dog(this.breed, String color):super("Black"){ this.color=color; // WE SHOULD PUT THIS HERE print("Dog class constructor"); } super("Black") causes confusion. If you write super(color) it doesnt matter but if you write super("Black") it matters. So if you write super("Black") you have to put this.color=color in Dog class i think. I tried.
@hellolife7753
@hellolife7753 4 года назад
what is the difference between methods and constructors?
@parikumari7004
@parikumari7004 2 года назад
It's very complicated, i can't understand how can we use it in real life project???
@yashveernathawat8154
@yashveernathawat8154 4 года назад
What is implicit call?
@almas8933
@almas8933 4 года назад
what if i dont want to call parent constructor?
@avi8034
@avi8034 4 года назад
1:25 you said it will implicitly print , ' Animal class constructor ' , 'Dog class constructor' twice but in my code even with using super () it printed just once . I want to ask that is it something change in Dart since then or what ? My code is below : class Person { Person() { // Default Constructor print("Parent class Constructor"); } void work (){ // Function print("Person needs job"); } } class Employee { Employee() : super() { // Default Constructor print("Child class Constructor"); } void work () { // Function print("Employee works hard"); } } output : Parent class Constructor Person needs job Child class Constructor Employee works hard
@akashtdm
@akashtdm 4 года назад
show ur main function
@akashtdm
@akashtdm 4 года назад
in ur code ur class employee doesn't have a super class(another class)...It does not inherit Person Class ...To make it work - class Employee extends Person{}
@degeneratetech1045
@degeneratetech1045 4 года назад
how to pass named parameter into super()?
@avi8034
@avi8034 4 года назад
This is the only video i couldn't understand . You put parameters in the constructor and there is no change in output ?? Hard to understand for absolute beginner like me .
@attimeequalszero6750
@attimeequalszero6750 4 года назад
Hi, Tried to summarize the contents of this lesson. Hope this helps. Stay safe. /* * Section 00:00 - 02:34 (Aim : Implicit super constructor calling and execution sequence) * 1. When dog class object is created there is a call to Dog class contructor as well * as Animal class contructor. This means the Animal class constructor is implicitly * (Automatically) executed when Dog class object is created. * 2. There is a implicit call child_class_constructor() : super_class_consrtuctor() * * Section 02:34 - 04:30 (Aim: Parameterised constructors and effect on call and execution sequence ) * 1. When the constructor in child class is modified as * child_class_constructor(Parameter_1, etc) : super_class_consrtuctor(Parameter1. etc) * The constructor in super class has to be modified accordingly(match the parameters) * 2. By default : * 2.1 If the super class has a zero argument(no parameter) constructor * The default super class constructor is implicitly called from child class * Explicit call like this is not necessary * child_class_constructor() : super_class_consrtuctor() * 2.2 If the super class has a parameterised constructor * then it is compulsory to call the parameterised super class constructor from child class * like this child_class_constructor(Parameter_1, etc) : super_class_consrtuctor(Parameter1. etc) * * Section 04:30 - 05:40 (Aim: Passing values to super class constructor while creating child class object) * 1. While creating the child class object, values are passed as * ChildClass child_reference = new ChildClass(value_for_child_class_instance_variable, value_for_super_class_instance_variable); * According to the variable names, In the child class constructor values will be passed to the super class constructor * like this child_class_constructor(value_for_child_class_instance_variable, value_for_super_class_instance_variable) : super_class_consrtuctor(value_for_super_class_instance_variable) * * Section 05:50 - 10:40 (Aim: Named constructor, almost all of the above explanation is same) * */
@avi8034
@avi8034 4 года назад
@@attimeequalszero6750 good
@avi8034
@avi8034 4 года назад
@@attimeequalszero6750 1:25 He said it will implicitly print , ' Animal class constructor ' , 'Dog class constructor' twice but in my code even after using super (), it printed just once . I want to ask that is it something change in Dart since then or what ? My code is below : class Person { Person() { // Default Constructor print("Parent class Constructor"); } void work (){ // Function print("Person needs job"); } } class Employee { Employee() : super() { // Default Constructor print("Child class Constructor"); } void work () { // Function print("Employee works hard"); } } output : Parent class Constructor Person needs job Child class Constructor Employee works hard
@attimeequalszero6750
@attimeequalszero6750 4 года назад
@@avi8034 Hi, You have missed out using the extends keyword. Without using extends keyword the Person class wont be inherited by the Employee class. Like this : class Employee extends Person { //code } Hope this helps. Stay safe.
@avi8034
@avi8034 4 года назад
@@attimeequalszero6750 oh thank you so much sir ! stay safe you too sir !
@muralidharan2044
@muralidharan2044 4 года назад
y do u show every time its the same output when there is no changes. so confusing. instead just say how to write proper code with out errors. just show the error displayed.
@anonekomous2
@anonekomous2 3 года назад
class parent { parent() { print('parent constructor called.'); } void disp() { print('disp was called'); } } class chid1 extends parent { child() { print('child constructor was called'); } } void main() { parent p1 = new parent(); p1.disp(); }/// code for reference i have executed this code and the output is as follows output: parent constructor called disp was called my doubt: since i just made an object of the parent class the parent constructor(which is a default constructor) was called and since i didnt make any child object the child constructor wasn't called thus which in turn would implicitly call the parent constructor but if i make the parent constructor as parameterised it would throw the error that it has no zero args but i dont get why is the compiler throwing me an error since i am not making an call to the child class i would directly make an object of the parent class and send the necessary args but it would still show me the error that the super class constructor has no zero args.
@shubhamdubey1996
@shubhamdubey1996 5 лет назад
class Dog extends Animal { var name; //var breed, color ; //Inherited from Animal //Dog(this.name, this.breed, this.color); //Not Working, Error : breed and color isn't a + //+field in enclosing class. Dog() { this.name = name; this.breed = breed; //but here in same class, It works. Why? this.color = color; } void bark() => print("$name is Barking"); } Help Needed :)
@smartherd
@smartherd 5 лет назад
Check. Source code link in description
@israekids-7019
@israekids-7019 6 лет назад
changer icone de vidéo ce icone ne pas comprendre, écrire Pas assez
@MAURICIOUSFRIMPONG
@MAURICIOUSFRIMPONG 3 месяца назад
this one dee3 boss i did not see top
@captionland2955
@captionland2955 4 года назад
tHE sAME OUTPUT Confuses a lot of people.
@muralidharan2044
@muralidharan2044 4 года назад
11.34 Wrong pint 3- you cant do without a default constructor. if you are having a custom constructor its a must to have a default constructor. what you can say in propr way in point 3 is= if you have a more constructor in parent class, choose the the one you want. if u call default then its super() if you call named constructor its super.anyname() your point 3 is confusing english
@saivishnu725
@saivishnu725 4 года назад
This is the only video in the entire course , i can admit i was disappointed , the video was okay but it would be nice if you would have outputted those breed and color to make it more clear
@jayanthbit2051
@jayanthbit2051 4 года назад
whoever think you are not finding any real world application for classes and objects, you are coding in a wrong way
@roverojermainemariongilr.2856
@roverojermainemariongilr.2856 2 года назад
This is really confusing for me LOL
@sealandland3959
@sealandland3959 2 года назад
what is the meaning of "porfect"? and "vi vil"? is this even English?
@nuwansuranjith6553
@nuwansuranjith6553 Год назад
His examples make no sense.
Далее
🧙‍♀️☃️💥 #ice #icequeen #winter
00:14
Просмотров 61 тыс.