HsViewModel<M extends HsModel> class
abstract
- ViewModel HsViewModel
- Inheritance
-
- Object
- BaseHiveState<
M> - HiveState<
M> - HsViewModel
- Mixed-in types
- Available extensions
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- initValue → M?
-
initValue 初始值
如果不想设置初始值, 请return null;
如果要需要异步初始化, 请return null, 并覆写onCreate 函数
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stream
→ Stream<
M> -
no setterinherited
-
subject
→ StreamController<
M> -
no setterinherited
- value → M
-
no setterinherited
- valueOrNull → M?
-
如果没有初始值, 则value可能为null,使用valueOrNull避免抛出异常
no setterinherited
Methods
-
combineStream(
List< BaseHiveState> ? combines) → CombineLatestStream<dynamic, List> -
合并多个HiveState, 任意一个HiveState更新,都会产生新的event
返回值: List, 按顺序返回每一个Stream的最新的值; 由于每个Stream的类型可能不同, 所以类型为List
inherited
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
override
-
dispose(
) → void -
============== 以下是高级功能, 一般情况下无需使用 ==============
释放内存
inherited
-
logger(
String message, {DateTime? time, int? sequenceNumber, int level = 0, String? name, Zone? zone, Object? error, StackTrace? stackTrace}) → dynamic -
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCreate(
{M? initValue}) → StreamController< M> -
通过覆写onCreate,可以实现在首次创建subject时设置初始数据
T
实例 但如果初始值不是固定值, 则需要通过BaseHiveState.init
设置初始值T
实例 注意: 一般情况下, 是在Widget的initState方法中调用 put 值进行初始化;inherited -
put(
M value) → BaseHiveState< M> -
inherited
-
putError(
Object e, [StackTrace? s]) → BaseHiveState< M> -
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toProvider(
{Key? key, dynamic onCreated(VM vm)?, Dispose< VM> ? dispose, bool? lazy, TransitionBuilder? builder, Widget? child}) → dynamic -
Available on HsViewModel<
HsModel> , provided by the HsViewModelX extension -
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A brief description of this object, usually just the runtimeType and the
hashCode.
inherited
-
update(
FutureOr< M> update(M old), {dynamic onError(Object e, StackTrace s)?}) → Future<void> -
执行一个异步操作, 并更新状态
不建议对本方法进行二次包装, 因此返回值强制为 void
inherited
-
updateOrNull(
FutureOr< M> update(M? old), {dynamic onError(Object e, StackTrace s)?}) → Future<void> -
if State init value is
null
, you can use updateOrNullinherited -
valueToString(
M? value) → String -
putError中, 将会打印model值
value
覆写本函数, 返回需要打印的内容inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited