Constructor In Dart - Learn Dart Programming

preview_player
Показать описание
This video covers information about constructor in dart. You will learn how to create constructor with different examples.

Timestamp For Video:
00:00 - 00:15 Introduction to Constructor
00:15 - 18:04 Demo of Constructor
18:04 - 18:27 Conclusion

Connect With Me:

#Dart #Constructor #DartConstructor #ConstructorInDart #LearnDart
Рекомендации по теме
Комментарии
Автор

class Patient{
String? name;
int? age;

Patient(this.name, this.age);
}

void main() {
Patient p = Patient("jay", 21);
print(p.name);
print(p.age);
}

jaydobariya
Автор

i dont understand why should we use constructor? i mean if you didnt put the constructor, i still works way the same right? just change the void display to

void display (){
print ("Name is $name");
print ("Age is $age");
}

StefenTjung
Автор

class Patient {
String? name;
int? age;
String? disease;

Patient(String name, int age, String disease) {
this.name = name;
this.age = age;
this.disease = disease;
}

void display() {
print("Name is $name");
print("age is $age");
print("Disease is $disease");
}
}

void main(List<String> args) {
Patient patient = Patient("vikram", 33, "typhoid");
patient.display();
}

BankITOfficer
Автор

you are really handsome in this video, keep up the good work.

Кыргызстан-менинмекеним
Автор

🤔It's a bit difficult for me. I will watch all your video and come back to this video again. 😅😁 Thank you!!

becborahm
Автор

class Patient {
String? name;
int? age;
String? disease;

Patient(String name, int age, String disease) {
this.name = name;
this.age = age;
this.disease = disease;
}
}

void main() {
Patient patient = Patient("Harry", 23, "flue");
print(patient.name);
print(patient.age);
print(patient.disease);
}

Achchabl
Автор

class Patient {
String? name;
int? age;
String? disease;

Patient(this.name, this.age, this.disease);

void display(){
print( 'Name: $name');
print('Age: $age');
print('Disease: $disease');
}
}



void main(){

Patient pacient= Patient('Lui', 19, 'Sobrepreso');
pacient.display();
}

Lui_Catarino
Автор

class Patient {
String? name;
int? age;
String? disease;

//creating constructor
Patient(n, a, d) {
this.name = n;
this.age = a;
this.disease = d;
}
}

void main() {
Patient patient = Patient("Ram", 33, "Cancer");
print(patient.name);
print(patient.age);
print(patient.disease);
}

bornlearn
Автор

class Patient {
String? name;
int? age;
String? disease;

Patient(this.name, this.age, this.disease);


void display(){
print("The patient name is ${this.name}");
print("The patient age is ${this.age}");
print("The patient disease is ${this.disease}");
}
}

void main() {
Patient p = Patient("Abebe", 30, "Ameba");
p.display();


}

zionof
Автор

Class Patient (){
String? name;
int? age;
String? disease;

Patient ({this.name, this.age, this.disease});

void print (){
print("Name: ${this.name} ;
print("Name: ${this.age} ;
print("Name: ${this.disease} ;
}
}


void main () {
Patient p1 = Person("Wooble", 10, "Stomatche")
p1.display();
}

StefenTjung
Автор

patient.dart

class Patient {
String? name;
int? age;
String? illness;

Patient({required this.name, required this.age, required this.illness}) {}

void display() {
print("patient name is ${this.name}");
print("patient age is ${this.age}");
print("patient illness is ${this.illness}");
}
}

main.dart

import 'patient.dart';
void main() {
Patient p1 = Patient(name: "Ibrahim", age: 21, illness: "grip");
p1.display();
}

ibrahimcetin