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

  Рет қаралды 48,844

Smartherd

Smartherd

Күн бұрын

Пікірлер: 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 😂😂😂😂
@BotanAbdullah
@BotanAbdullah 6 жыл бұрын
By far the best tutorial about Dart on KZbin.
@smartherd
@smartherd 6 жыл бұрын
thanks alot
@thiruvenkatasamypranesh80
@thiruvenkatasamypranesh80 10 ай бұрын
@@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
@jangeisler6961
@jangeisler6961 5 жыл бұрын
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
@ishaqkhan4508
@ishaqkhan4508 4 жыл бұрын
AWESOME VIDEO.TO THOSE WHO DIDNT GET IT YOU SHOULD PRACTICE THESE ATLEAST FOR ONE WHOLE DAY
@fclinuxnova7977
@fclinuxnova7977 4 жыл бұрын
this is super crazy video content to the newbie, I wish to do the same in my small project ... :D
@muhammadyusoffjamaluddin
@muhammadyusoffjamaluddin 5 жыл бұрын
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.
@ozgurozdemir8224
@ozgurozdemir8224 2 жыл бұрын
Thank you for this clean lesson.
@smartherd
@smartherd 2 жыл бұрын
Namaste
@mateusvenancio
@mateusvenancio 3 жыл бұрын
Great video thank you!
@user-or7ji5hv8y
@user-or7ji5hv8y 5 жыл бұрын
Very clear explanation
@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??
5 жыл бұрын
I've understood nothing :(
@peekpt
@peekpt 6 жыл бұрын
Nice work following this tutorial everyday!
@indiancodingclub
@indiancodingclub 5 жыл бұрын
sir plzz make more vedios on flutter or dart your vedios are great
@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!
@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?
@captionland2955
@captionland2955 4 жыл бұрын
tHE sAME OUTPUT Confuses a lot of people.
@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?
@anoundhim4393
@anoundhim4393 6 жыл бұрын
please create constuctor overiding with parameters and it's possible for use optional parameters? please give example
@rajdhakad7380
@rajdhakad7380 6 жыл бұрын
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..
@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{}
@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.
@realityandtruth9662
@realityandtruth9662 3 жыл бұрын
hello sir please help me.. Is flutter app size too big ? it is rumour or true sir...
@hellolife7753
@hellolife7753 4 жыл бұрын
what is the difference between methods and constructors?
@yashveernathawat8154
@yashveernathawat8154 4 жыл бұрын
What is implicit call?
@TevaIllathaAani
@TevaIllathaAani 5 жыл бұрын
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.
@karthickrajalearn
@karthickrajalearn 5 жыл бұрын
In 2m 02sec Thanks for Introducing In 4m 01sec In 4m 43sec
@Allen-ih1fc
@Allen-ih1fc 5 жыл бұрын
Good job! Bro
@almas8933
@almas8933 4 жыл бұрын
what if i dont want to call parent constructor?
@krishnakumarramachandran5888
@krishnakumarramachandran5888 6 жыл бұрын
Super Sir.
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.
@arshadsaid3154
@arshadsaid3154 Жыл бұрын
Wow it actually looks like java but shorter😮
@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 !
@righteous-wend
@righteous-wend 6 жыл бұрын
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 6 жыл бұрын
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.
@parikumari7004
@parikumari7004 2 жыл бұрын
It's very complicated, i can't understand how can we use it in real life project???
@degeneratetech1045
@degeneratetech1045 4 жыл бұрын
how to pass named parameter into super()?
@shubhamdubey1996
@shubhamdubey1996 6 жыл бұрын
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 6 жыл бұрын
Check. Source code link in description
@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.
@israekids-7019
@israekids-7019 6 жыл бұрын
changer icone de vidéo ce icone ne pas comprendre, écrire Pas assez
@MAURICIOUSFRIMPONG
@MAURICIOUSFRIMPONG 7 ай бұрын
this one dee3 boss i did not see top
@TevaIllathaAani
@TevaIllathaAani 5 жыл бұрын
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 3 жыл бұрын
This is really confusing for me LOL
@sealandland3959
@sealandland3959 3 жыл бұрын
what is the meaning of "porfect"? and "vi vil"? is this even English?
@nuwansuranjith6553
@nuwansuranjith6553 2 жыл бұрын
His examples make no sense.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Failed a Technical Interview Because of This Code
22:08
Cosden Solutions
Рет қаралды 17 М.
Master Local AI with DeepSeek-R1 In 10 Minutes
9:23
Jacob Geiger
Рет қаралды 8 М.
Event Sourcing for .NET Developers: From Zero to Implementation
19:55
Milan Jovanović
Рет қаралды 10 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 314 М.
Ranking Java Features Added from Versions 8 to 21!
27:03
Tales from the jar side
Рет қаралды 14 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science Lessons
Рет қаралды 989 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН