MyService<T> class

服务注册类,用于注册GetX服务

支持同步和异步服务初始化:

  • 同步服务:使用 service 参数
  • 异步服务:使用 asyncService 参数

示例:

// 同步服务
MyService<SettingsService>(service: () => SettingsService())

// 异步服务(需要异步初始化,如从数据库/网络加载配置)
MyService<ChatService>(asyncService: () async => ChatService())

Constructors

MyService({T service()?, Future<T> asyncService()?, bool permanent = false, bool fenix = false, String? tag})

Properties

asyncService Future<T> Function()?
final
fenix bool
final
hashCode int
The hash code for this object.
no setterinherited
permanent bool
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
service → T Function()?
final
tag String?
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerService() Future<void>
注册服务到GetX依赖注入系统
toString() String
A string representation of this object.
inherited

Operators

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