BaseBinding class

Base binding class for GetX dependency injection.

BaseBinding extends GetX's Bindings class and serves as a foundation for implementing dependency injection across the application. It provides a centralized place to register controllers, services, and other dependencies.

Subclasses should override dependencies to register their specific dependencies using GetX's Get.put, Get.lazyPut, or Get.putAsync methods.

Example:

class HomeBinding extends BaseBinding {
  @override
  void dependencies() {
    super.dependencies(); // Call parent if needed
    Get.lazyPut(() => HomeController());
    Get.put(UserService());
  }
}

// Usage with GetX routing
GetPage(
  name: '/home',
  page: () => HomeView(),
  binding: HomeBinding(),
);

Dependency injection strategies:

  • Get.put(): Creates instance immediately and keeps it in memory
  • Get.lazyPut(): Creates instance only when first accessed
  • Get.putAsync(): Creates instance asynchronously

See also:

Inheritance

Constructors

BaseBinding()

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

dependencies() → void
Registers dependencies for this binding.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited