I'm stunned by your comprehensiveness, I could not find so minute details explained about every topic and keyword elsewhere. You're a dart documentation in a human form.
Thank You so much for giving a real world example of what, to the newbie, is a complex subject. Many videos deal in the abstract that may show you what to do but miss out the why you’d want to do something.
EXCELLENT tutorial; content thoroughly covered by good teacher! Thinking his ‘Flutter Course’ and ‘Dart Basic’ playlists look really good … and very current.
Thanks. It wasnt’ till the end of the tutorial that I understood what returning a sub-class instance of a class instead of the class itself meant. It was a light-bulb moment
First of all thank you for your effort I have a question, why declaring city and object variables out of the if statement but still inside for in loop give me an error
Johan, I have been watching all your videos on your Dart and trying to practice also. At times, I need to refer back to previous video and code snippets. Is there is a gist or git that I can refer for all the code that was covered in the video tutorials. Thanks a bunch
print(reading) basically calls toString method of the Reading and it's subclasses. This method returns a string. Since any object inherits Object class, you can override this method to return a custom string, as shown in the video. If you don't override it then it will print 'Instance of Reading' or 'Instance of Temperature' or 'Instance of Pressure' depending on the object type basically 'Instance of ' . tldr: print() method in the last for loop calls toString method of the readings, which prints the strings returned by the overridden toString methods of these readings.
Dart developing team should put all of your videos on their website. The explanation of the factory constructor was amazing. Thank you
Agree
I'm stunned by your comprehensiveness, I could not find so minute details explained about every topic and keyword elsewhere. You're a dart documentation in a human form.
Thank You so much for giving a real world example of what, to the newbie, is a complex subject.
Many videos deal in the abstract that may show you what to do but miss out the why you’d want to do something.
Thank you Johan. For the first time I have a proper understanding of factory constructors in Dart.
Awesome!
Can you help me how to add null safty in factory constructor plz plz
Thanks man! 4 years of coding and now I found the purpose of factory constructor and finally understood this concept. Well explained!
EXCELLENT tutorial; content thoroughly covered by good teacher! Thinking his ‘Flutter Course’ and ‘Dart Basic’ playlists look really good … and very current.
Another excellent video tutorial explaining in a very simple way by Johan.
Finally, watching this episode, I understand what the factory constructor is. Thanks.
Can you help me how to add null safty in factory constructor plz plz
most complete dart tutorials...thanks
Great video!!! It is the best tutorial I have seen of the factory constructor.
Thank you very much.
Holy moly, this is such a good explanation.
Thanks. It wasnt’ till the end of the tutorial that I understood what returning a sub-class instance of a class instead of the class itself meant. It was a light-bulb moment
Great!
Very well done tutorial! Thank you!
First of all thank you for your effort
I have a question, why declaring city and object variables out of the if statement but still inside for in loop give me an error
Great example, thank you !
what is the method of starting conversion with you
Great video!
Johan, I have been watching all your videos on your Dart and trying to practice also. At times, I need to refer back to previous video and code snippets. Is there is a gist or git that I can refer for all the code that was covered in the video tutorials. Thanks a bunch
Hi, sorry. Not really for Dart. I tried to do it for Flutter.
Link from the video: www.learndartprogramming.com/fundamentals/factory-constructor-in-dart/
Hi sorry the question, but why the toString runs automatically?
print(reading) basically calls toString method of the Reading and it's subclasses. This method returns a string. Since any object inherits Object class, you can override this method to return a custom string, as shown in the video. If you don't override it then it will print 'Instance of Reading' or 'Instance of Temperature' or 'Instance of Pressure' depending on the object type basically 'Instance of ' .
tldr: print() method in the last for loop calls toString method of the readings, which prints the strings returned by the overridden toString methods of these readings.
Thank you!
awesome. thanks
Hi Johan, maybe I couldn't find in your channel a video for generic classes, did you make one by any chance? Great video this one, by the way.
I dont think so. Good one to add. thanks
@@JohanJurrius Lots of people will appreciate it, i am 💯 sure
@@JohanJurrius I will really appreciate it a lot.
bro how u not famous.. the video so good lmao
Can you help me how to add null safty in factory constructor plz plz
@@saurabhgaming1531 i have similar problem at past.. i can help u.. if i remember the solution.. pm me?
@@saurabhgaming1531 need to see the code
@@saurabhgaming1531 wan_hahaha
@@trapeye3464 bro I am unable to get your I'd plz hel me I cant share link here also it get automatically deleted after 29 sec
nice explanation !!
Thank you very much!
fantasic video!
Thanks you sir, resepect!
Hello I am creating in latest versions but how to add null safty in factory constructor
Could you give me an example of what you want to do in a gist and I can check if I can help?
I will need to see your code
You can create a gist on github. Really fast.
I am un able to share link of gist yotube delete my comments plz help me
Hope this helps someone out:
class Reading {
double value;
Reading({required double value}) : this.value = value;
Reading.zero() : value = -999;
@override
String toString() {
return '$value';
}
}
class Temperature extends Reading {
String city;
Temperature({required String city, required double reading})
: this.city = city,
super(value: reading);
Temperature.zero()
: city = '',
super(value: -999);
@override
String toString() {
return 'Temperature reading:
Reading: ${super.toString()}
City: $city
';
}
}
class Pressure extends Reading {
String objectTested;
Pressure({required String objectTested, required double reading})
: this.objectTested = objectTested,
super(value: reading);
Pressure.zero()
: objectTested = '',
super(value: -999);
@override
String toString() {
return 'Pressure reading:
Reading: ${super.toString()}
Object Tested: $objectTested
';
}
}
void main() {
var fromServer = [
{
'type': 'temp',
'reading': 20.2,
'city': 'Johannesburg',
},
{
'type': 'pressure',
'reading': 100.0,
'object': 'Glass Cylinder',
},
{
'type': 'temp',
'reading': 35.2,
'city': 'New York',
},
{
'type': 'pressure',
'reading': 300.5,
'object': 'Tire',
}
];
}