You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quite a few lines per property are needed currently, and you need to keep Strings of your property names around, which is error prone and not compile time safe.
The below example takes 10 lines to implement 1 property.
class MyModel with PropertyChangeNotifier<String> {
int _foo = 0;
int get foo => _foo;
set foo(int value) {
_foo = value;
notifyListeners('foo');
}
set bar(int value) {
_bar = value;
notifyListeners('bar');
}
}
Recommended syntax
class MyModel with PropertyChangeNotifier<String> extends $MyModel {
@PropertyNotifiy
int _$foo = 0;
}
The idea is that the required code would be generated, creating a public getter and setter of foo in $MyModel. Then, extending $MyModel gives you those properties on MyModel. This reduces the lines of code to 2 per property and removes the property name String.
The text was updated successfully, but these errors were encountered:
I may be able to, I recently started a project very similar to this, but codegen was a mandatory feature for me to reduce lines of code to implement each property. May just move my efforts here instead.
Quite a few lines per property are needed currently, and you need to keep Strings of your property names around, which is error prone and not compile time safe.
The below example takes 10 lines to implement 1 property.
Recommended syntax
The idea is that the required code would be generated, creating a public getter and setter of
foo
in$MyModel
. Then, extending$MyModel
gives you those properties onMyModel
. This reduces the lines of code to 2 per property and removes the property name String.The text was updated successfully, but these errors were encountered: