Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'depth' isn't defined for the type 'FilterableQuery'. #17

Open
notan1 opened this issue Jun 6, 2020 · 1 comment
Open

'depth' isn't defined for the type 'FilterableQuery'. #17

notan1 opened this issue Jun 6, 2020 · 1 comment

Comments

@notan1
Copy link

notan1 commented Jun 6, 2020

I try to fetch comments for a post with the provided example code:

reddit.sub("dartlang").comments("2ek93l").depth(3).fetch().then(print);

"depth(3)" is marked as error with following message:

The method 'depth' isn't defined for the type 'FilterableQuery'.
Try correcting the name to the name of an existing method, or defining a method named 'depth'. dart(undefined_method)

reddit version: 0.6.0
[✓]Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.4 19E266, locale de-DE)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)

@stevenroose
Copy link
Owner

Weird. It should be handled by the noSuchMethod implementation. Is that no longer correct Dart? It's been a long while.

Well alterntively, .depth(3) is the same as .filter("depth", 3)..

  @override
  noSuchMethod(Invocation inv) {
    if (inv.isMethod == false) {
      return new NoSuchMethodError(
          this, inv.memberName, inv.positionalArguments, inv.namedArguments);
    }
    if (inv.positionalArguments.length > 1 || inv.namedArguments.length > 0) {
      throw new StateError(
          "Filter methods take zero or one positional arguments.");
    }
    String symbol = inv.memberName.toString();
    String f = symbol.substring(8, symbol.length - 2);
    return filter(f,
        inv.positionalArguments.isEmpty ? null : inv.positionalArguments.first);
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants