Skip to content

Instantly share code, notes, and snippets.

@shyndman
Last active March 12, 2020 04:30
Show Gist options
  • Select an option

  • Save shyndman/4541ffc0e8ec013dd21a8b504d2eef05 to your computer and use it in GitHub Desktop.

Select an option

Save shyndman/4541ffc0e8ec013dd21a8b504d2eef05 to your computer and use it in GitHub Desktop.

Revisions

  1. Scott Hyndman revised this gist Mar 12, 2020. 1 changed file with 9 additions and 0 deletions.
    9 changes: 9 additions & 0 deletions const_with_functions.dart
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,13 @@ bool standardEquality(Object a, Object b) => a == b;
    class Foo {
    @observable(standardEquality)
    bool flag;

    @observable(Foo.equals)
    Foo child;

    static bool equals(Object a, Object b) => a == b;
    }

    void main() {
    final foo = Foo();
    }
  2. Scott Hyndman created this gist Mar 12, 2020.
    11 changes: 11 additions & 0 deletions const_with_functions.dart
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    class observable {
    const observable(this.comparator);
    final bool Function(Object a, Object b) comparator;
    }

    bool standardEquality(Object a, Object b) => a == b;

    class Foo {
    @observable(standardEquality)
    bool flag;
    }