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

IssuesService.get fails, type cast error #124

Closed
HansMuller opened this issue Nov 21, 2018 · 2 comments
Closed

IssuesService.get fails, type cast error #124

HansMuller opened this issue Nov 21, 2018 · 2 comments

Comments

@HansMuller
Copy link

The following app fails with 4.0.0 of the github package and the 2.1.0-dev.9.4 version of Dart used by the flutter project:

import 'dart:async';
import 'package:github/server.dart';

void main() {
  GitHub github = createGitHubClient(auth: new Authentication.withToken(myToken));
  RepositorySlug slug = RepositorySlug("flutter", "flutter");
  github.repositories.getRepository(slug).then((Repository repository) {
    github.issues.get(slug, 22781).then((Issue issue) {
      print(issue.htmlUrl);
    });
  });
}

Here's the swan song:


Unhandled exception:
type 'List<dynamic>' is not a subtype of type 'List<Map<String, dynamic>>' in type cast
#0      Issue.fromJSON (... pub.dartlang.org/github-4.0.0/lib/src/common/model/issues.dart:64:34)
#1      GitHub.getJSON (... pub.dartlang.org/github-4.0.0/lib/src/common/github.dart:226:32)
<asynchronous suspension>
#2      IssuesService.get (file:///usr/local/google/home/hansmuller/.pub-cache/hosted/pub.dartlang.org/github-4.0.0/lib/src/common/issues_service.dart:141:15)
#3      main.<anonymous closure> (package:issues/main.dart:9:19)

I tried the app with Dart VM version: 2.0.0-dev.36.0 since the package claims to support that version.

NoSuchMethodError: Attempted to use type 'IOClient' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the IOClient constructor and forget the 'new' operator?
Receiver: IOClient
Tried calling: IOClient()
#0      Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)
#1      createClient (package:http/src/io_client.dart:16:38)
#2      new Client (package:http/src/client.dart:35:23)
#3      new GitHub (package:github/src/common/github.dart:48:44)
#4      createGitHubClient (package:github/server.dart:20:14)
#5      main (file:///usr/local/google/home/hansmuller/issues/lib/main.dart:6:19)

@pq
Copy link
Contributor

pq commented Dec 22, 2018

Oh yeah, looks like a bunch of dynamic casts need updating.

(Still an issue on head (2.2.0-edge.0a0ee50501843425e1ba1cb090d9e0a2f42e9371 (Fri Dec 21 23:47:23 2018 +0000)).)

@pq
Copy link
Contributor

pq commented Dec 22, 2018

I took a quick crack at a fix (#126).

@HansMuller, if you update your dev_dependencies like this,

  github:
    git:
      url: git://github.com/pq/github.dart.git
      ref: issue_cast_fixes

you might get unblocked in the short-term.

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