Skip to content

Instantly share code, notes, and snippets.

@mg
Created October 7, 2020 10:31
Show Gist options
  • Select an option

  • Save mg/d141dbc29d99d81e45dc016e959fb1e1 to your computer and use it in GitHub Desktop.

Select an option

Save mg/d141dbc29d99d81e45dc016e959fb1e1 to your computer and use it in GitHub Desktop.

Revisions

  1. mg created this gist Oct 7, 2020.
    21 changes: 21 additions & 0 deletions list.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    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
    }