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

Unhandled Exception: type 'String' is not a subtype of type 'int?' #1

Closed
Flajt opened this issue Jun 28, 2021 · 2 comments
Closed

Unhandled Exception: type 'String' is not a subtype of type 'int?' #1

Flajt opened this issue Jun 28, 2021 · 2 comments

Comments

@Flajt
Copy link

Flajt commented Jun 28, 2021

Hello, I'm currently trying to use your package in a project and get this error: Unhandled Exception: type 'String' is not a subtype of type 'int?'
My code:

static Future<List<JikanAnimeDetails?>> get() async {
    Jikan j = Jikan();
    List<JikanAnimeDetails?> jikanArray = [];
    List dataArray = await JikanWrapper.getTop();
    Future.forEach<dynamic>(dataArray, (element) async {
      if (element != null) {
        JikanResult<JikanAnimeDetails?> result = await j.getAnime(animeId: element["mal_id"]);
        if (result.hasData) jikanArray.add(result.response);
      }
    });
    return jikanArray;
  }

Stacktrace: (Sorry for the odd formatting)

E/flutter (12547): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: type 'String' is not a subtype of type 'int?'
E/flutter (12547): #0      new JikanError.fromJson package:dart_jikan/…/models/error.dart:34
E/flutter (12547): #1      new JikanError.fromRawJson package:dart_jikan/…/models/error.dart:29
E/flutter (12547): #2      request package:dart_jikan/…/utils/request.dart:18
E/flutter (12547): <asynchronous suspension>
E/flutter (12547): #3      JikanAnimeEndpoints.getAnime package:dart_jikan/…/endpoints/anime.dart:11
E/flutter (12547): <asynchronous suspension>
E/flutter (12547): #4      GetTopAnime.get.<anonymous closure> package:amvia/Logic/GetTopAnime.dart:14
E/flutter (12547): <asynchronous suspension>
E/flutter (12547): #5      _CustomZone.bindUnaryCallbackGuarded.<anonymous closure> (dart:async/zone.dart)
E/flutter (12547): <asynchronous suspension>
E/flutter (12547):

My guess from the stacktrace is that the error would be that the deserialization to the JikanError is the issue.
From the message I would guess maybe the error code is a string instead of an int, but that feels somewhat wrong.

Oddly enough a hot reload seems to somehow fix it (but only temporary), so maybe my code is broken.
EDIT: I just tried if with a regular for inloop,same result, here a hot restart doesn't fix anything.

xamantra pushed a commit that referenced this issue Jul 1, 2021
@xamantra
Copy link
Owner

xamantra commented Jul 2, 2021

@Flajt I released a new version on pub.dev trying to resolve this issue.

@Flajt
Copy link
Author

Flajt commented Jul 2, 2021

@xamantra Thanks a lot, it seems to work really well. I tried to simply say it's of type String, which sometimes worked but not always, so good that I didn't do a pull request with that "fix" of mine XD. And thank you again.

@xamantra xamantra closed this as completed Jul 2, 2021
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