getAllDeclaredMixins abstract method

List<Class> getAllDeclaredMixins()

Gets all directly declared mixins (non-transitive).

Returns:

  • List of mixins explicitly applied to this class
  • Empty list if no mixins declared
  • Does NOT include inherited mixins from superclasses

Declared vs All Mixins

  • getDeclaredMixins(): Only direct with declarations
  • getAllMixins(): Includes inherited mixins from hierarchy

Example:

mixin Loggable {}
mixin Cacheable {}
class BaseService with Loggable {}
class UserService extends BaseService with Cacheable {}

final userClass = Class.forType<UserService>();
final declared = userClass.getAllDeclaredMixins();  // [Cacheable]
final all = userClass.getAllMixins();               // [Cacheable, Loggable]

Implementation

///
  /// {@template class_get_all_declared_mixins}
  /// Returns:
  /// - List of mixins explicitly applied to this class
  /// - Empty list if no mixins declared
  /// - Does NOT include inherited mixins from superclasses
  ///
  /// ## Declared vs All Mixins
  /// - **getDeclaredMixins()**: Only direct `with` declarations
  /// - **getAllMixins()**: Includes inherited mixins from hierarchy
  ///
  /// Example:
  /// ```dart
  /// mixin Loggable {}
  /// mixin Cacheable {}
  /// class BaseService with Loggable {}
  /// class UserService extends BaseService with Cacheable {}
  ///
  /// final userClass = Class.forType<UserService>();
  /// final declared = userClass.getAllDeclaredMixins();  // [Cacheable]
  /// final all = userClass.getAllMixins();               // [Cacheable, Loggable]
  /// ```
  /// {@endtemplate}
  List<Class> getAllDeclaredMixins();