Flutter 颤振-当模型中的ViewModel发生更改时,如何更新所有ViewModel中的更改';s属性

Flutter 颤振-当模型中的ViewModel发生更改时,如何更新所有ViewModel中的更改';s属性,flutter,mvvm,stacked,Flutter,Mvvm,Stacked,我在flatter中使用stackedpackage()作为MVVM体系结构。当ViewModel更改服务类中的属性时,我需要更新BaseModel中的更改。下面是我的代码摘要 class BaseModel extends ChangeNotifier { final AuthenticationService _authenticationService = locator<AuthenticationService>(); AppUser get current

我在flatter中使用stackedpackage()作为MVVM体系结构。当ViewModel更改服务类中的属性时,我需要更新BaseModel中的更改。下面是我的代码摘要

class BaseModel extends ChangeNotifier {

  final AuthenticationService _authenticationService =
  locator<AuthenticationService>();

  AppUser get currentUser => _authenticationService.currentUser;

}

class AuthenticationService {
  final FirebaseAuth _firebaseAuth = FirebaseAuth.instance;
  final FirestoreService _firestoreService = locator<FirestoreService>();

  AppUser _currentUser;
  AppUser get currentUser => _currentUser;

updateUser(AppUser user) {
    _currentUser = user;
  }

}

class UserProfileViewModel extends BaseModel {
final AuthenticationService _authenticationService = locator<AuthenticationService>();

Future updateUser() async{    
    AppUser user = AppUser(many properties);    
    await _authenticationService.updateUser(user);    
    notifyListeners();
  }

}
class BaseModel扩展了ChangeNotifier{
最终身份验证服务\u身份验证服务=
定位器();
AppUser get currentUser=>\u authenticationService.currentUser;
}
类身份验证服务{
final FirebaseAuth _FirebaseAuth=FirebaseAuth.instance;
最终FirestoreService_FirestoreService=locator();
AppUser\u currentUser;
AppUser get currentUser=>\u currentUser;
updateUser(应用程序用户){
_当前用户=用户;
}
}
类UserProfileViewModel扩展了BaseModel{
最终身份验证服务_AuthenticationService=locator();
Future updateUser()异步{
AppUser=AppUser(许多属性);
wait_authenticationService.updateUser(用户);
notifyListeners();
}
}
调用UserProfileViewModel.updateUser()时,AuthenticationService中的_currentUser成功更改,但是BaseModel中的currentUser不同步更新

我所尝试的: 我尝试过observable_ish包,但是,当我在AuthenticationService中实现ReactiveServiceMixin并将_currentUser包装在RxValue中时,我无法设置初始值。此外,AuthenticationService中的其他函数将_currentUser作为参数传递,也会收到错误消息。这样地:
wait _firestoreService.createUser(_currentUser)

您必须在
BaseModel
上更新
currentUser
。我不确定使用
UserProfileViewModel
inherit
BaseModel
的原因。继承类不会传递值

class BaseModel扩展了ChangeNotifier{
最终身份验证服务_AuthenticationService=locator();
AppUser get currentUser=>\u authenticationService.currentUser;
//更新用户
无效更新(AppUser){
_authenticationService.updateUser(用户);
notifyListeners();
}
}