FLUTTER : CLASSES AND OBJECTS

Опубликовано: 16 Февраль 2026
на канале: Showbilitix
467
7

In Flutter, classes and objects are fundamental concepts of object-oriented programming. A class is a blueprint or prototype that defines the properties (data) and behaviors (functions) that objects will have. An object is an instance of a class.

Here’s an example of a Student class in Dart:

class Student {
String lastName;
String firstName;
int schoolId;

Student({this.lastName, this.firstName, this.schoolId});
}

In this example, the Student class has three properties: lastName, firstName, and schoolId. The Student class also has a constructor that takes three named parameters: lastName, firstName, and schoolId. This constructor can be used to create new Student objects.

Here’s an example of creating a new Student object:

Student student = Student(
lastName: 'Batolata',
firstName: 'Pitok',
schoolId: 1,
);