Skip to main content

proper-getx-super-calls

added in: 1.19.0
🛠
Pro+

Checks that super calls in the onStart, onInit, onClose and onDelete methods are called in the correct order.

Example

❌ Bad:

class VideoViewerController extends GetxController {

void onInit() {
// some code

super.onInit(); // LINT: This 'super' call must come first.
}


void onStart() {
// some code

super.onStart(); // LINT: This 'super' call must come first.
}


void onClose() {
super.onClose(); // LINT: This 'super' call must come last.

// some code
}


void onDelete() {
super.onDelete(); // LINT: This 'super' call must come last.

// some code
}
}

✅ Good:

class VideoViewerController extends GetxController {

void onInit() {
super.onInit();

// some code
}


void onStart() {
super.onStart();

// some code
}


void onClose() {
// some code

super.onClose();
}


void onDelete() {
// some code

super.onDelete();
}
}