40 lines
1.9 KiB
Dart
40 lines
1.9 KiB
Dart
import 'package:get/get.dart';
|
|
import 'package:Intaleq/controller/auth/login_controller.dart';
|
|
import 'package:Intaleq/controller/firebase/firbase_messge.dart';
|
|
import 'package:Intaleq/controller/firebase/local_notification.dart';
|
|
import 'package:Intaleq/controller/home/deep_link_controller.dart';
|
|
import 'package:Intaleq/controller/local/local_controller.dart';
|
|
|
|
/// This is the central dependency injection file for the app.
|
|
/// It uses GetX Bindings to make the app start faster and manage memory better.
|
|
class AppBindings extends Bindings {
|
|
@override
|
|
void dependencies() {
|
|
// --- [Type 1: Permanent Controllers] ---
|
|
// Use Get.put() for controllers that need to be available immediately and ALWAYS.
|
|
// They are created right away and never destroyed.
|
|
|
|
// LocaleController is needed instantly to set the app's theme and language.
|
|
Get.put(LocaleController());
|
|
|
|
// DeepLinkController must always be listening for incoming links.
|
|
// `permanent: true` ensures it survives `Get.offAll()`.
|
|
Get.put(DeepLinkController(), permanent: true);
|
|
|
|
// --- [Type 2: Lazy Loaded "Phoenix" Controllers] ---
|
|
// Use Get.lazyPut() for controllers that are heavy or not needed immediately.
|
|
// They are only created in memory the first time `Get.find()` is called.
|
|
// `fenix: true` is the key: it allows the controller to be "reborn" after being
|
|
// destroyed (e.g., by Get.offAll), preserving its state and functionality.
|
|
|
|
// LoginController is only needed during the login process on the splash screen.
|
|
Get.lazyPut(() => LoginController(), fenix: true);
|
|
|
|
// NotificationController is initialized on the splash screen, but might be needed later.
|
|
Get.lazyPut(() => NotificationController(), fenix: true);
|
|
|
|
// FirebaseMessagesController is also initialized on splash, but must persist its token and listeners.
|
|
Get.lazyPut(() => FirebaseMessagesController(), fenix: true);
|
|
}
|
|
}
|