Skip to content

Instantly share code, notes, and snippets.

@mg
Created October 7, 2020 10:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mg/d141dbc29d99d81e45dc016e959fb1e1 to your computer and use it in GitHub Desktop.
Save mg/d141dbc29d99d81e45dc016e959fb1e1 to your computer and use it in GitHub Desktop.
class MyListNotifier extends ValueNotifier<MyList> {
MyListNotifier(MyList myList) : super(myList) {
value.setNotifyListeners(notifyListeners);
}
}
class MyList<E> extends List<E> {
VoidCallback _notifyListeners;
void setNotifyListeners(VoidCallback notifyListeners) {
this.notifyListeners = notifyListeners;
}
@override
void add(E element) {
super.add(element);
_notifyListeners();
}
// etc for needed mutating methods
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment