I have this class:

class LoginScreenState extends State<LoginScreen> implements OnLogin { 

   LoginVM _loginVM = LoginVM(this) // "this" doesn't work like Java for example.

   void onInvalidAccessToken() {

   void onInvalidRefreshToken() {

And this is the other:

abstract class OnLogin {
   void onInvalidAccessToken();
   void onInvalidRefreshToken();

Finally this is the class that should have the instance of OnLogin to call the callbacks.

class LoginVM {

  MyApi _api;
  AuthRepository _authRepository;
  OnLogin _onLogin;

  LoginVM(OnLogin _onLogin) {
    _api = MyApi.create();
    _authRepository = AuthRepository(_api);
    this._onLogin = _onLogin;

  void loginWithToken() async {
    var token = await _secureStorage.read(key: Constants.AUTH_TOKEN_KEY);
    if (token != null)
      _authRepository.getUser(token, _userStream);

  void loginWithRefreshToken() async {
    var refreshToken = await _secureStorage.read(key: Constants.AUTH_REFRESH_TOKEN_KEY);
    if (refreshToken != null)
      _authRepository.loginWithRefreshToken(refreshToken, _userStream);

  More code...


I would like to pass the OnLogin "interface" that implements the class with the keyword "this" like others languages, but it doesn't work in Dart.

Does anyone knows the way to do it?

Thanks a lot.