Classes Code your first Dart class

This lesson is available for PRO members or as a single course purchase. Sign-in and choose a plan below.
Get Unlimited PRO Access


*Enrollment provides full access to this course (and updates) for life.

Create a Class

Classes are a way to group data and behavior together, like a blueprint for an Object.

file_type_dartlang classes.dart
class Basic {
  int id;


  doStuff() {
    print('Hello my ID is $id');

Create an Object

Use the class to instantiate an Object. The new keyword is optional.

file_type_dartlang classes.dart
Basic thing = new Basic(55);;

Static Methods

You can call static methods on the class itself without creating a new object.

file_type_dartlang main.dart
class Basic {

  static globalData = 'global';
  static helper() {


Q&A Chat