registerEvent method
注册事件,从 Provider 中获取 ViewModel 数据,并调用 onRegisterEventByVm 方法
@param context 上下文对象,用于获取 Provider 中的数据 @param listen 是否监听数据变化,默认为 false
Implementation
void registerEvent(BuildContext context, {bool listen = false}) {
final vm = Provider.of<T>(context, listen: listen);
if (vm == null) {
throw Exception("Provider<T> not found in context");
}
valueWrap.data = vm;
onRegisterEventByVm(context, getVm());
}