Mobx.dart: NNBD: Nullable getters and setters don't get extended with the nullable type

Created on 2 Nov 2020  路  5Comments  路  Source: mobxjs/mobx.dart

Here's part of my store, which supports signing in and out:

abstract class _AuthStore with Store {
  @observable
  User? user;
}

And here's the generated code:

final _$userAtom = Atom(name: '_AuthStore.user');

@override
User get user {
  _$userAtom.reportRead();
  return super.user;
}

@override
set listener(User value) {
  _$userAtom.reportWrite(value, super.user, () {
    super.user = value;
  });
}

The generated getters and setters do not use the correct User? type, and instead use the non-nullable User. This does not compile.

Most helpful comment

NNBD is a fairly big change and we are working on it. It's currently not supported.

All 5 comments

NNBD is a fairly big change and we are working on it. It's currently not supported.

Understood, I just figured I should report this as I haven't seen it mentioned in any NNBD discussions.

Hi is there any updates? Since nullable observable values are very common

I have created a PR here (any suggestions and updates are welcomed!): https://github.com/mobxjs/mobx.dart/pull/631

Dupe of #598

Null safe versions have been published for mobx, flutter_mobx and mobx_codegen

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slavap picture slavap  路  4Comments

viktorszekeress picture viktorszekeress  路  4Comments

rrousselGit picture rrousselGit  路  6Comments

jiyarong picture jiyarong  路  4Comments

Tywholland picture Tywholland  路  3Comments