Skip to content

Instantly share code, notes, and snippets.

@Shuvo8693
Created February 25, 2024 23:33
Show Gist options
  • Save Shuvo8693/14f9edda5691bbeeacb2a03fdc4fd57a to your computer and use it in GitHub Desktop.
Save Shuvo8693/14f9edda5691bbeeacb2a03fdc4fd57a to your computer and use it in GitHub Desktop.
student details with OOP(Constructor Method)
void main() {
Student student = Student(); // here we can also provide values
student.sayHello();
print(student.getRollSquared());
student.getAddress();
}
class Student{
String name;
int roll;
String address;
Student({this.name='shuvo',this.roll=88,this.address='Uttarkhan'});
void sayHello(){
return print('Hello, My Name is $name');
}
int getRollSquared(){
return roll*roll;
}
void getAddress(){
return print('My location is $address');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment