RootSoft / algorand-dart

Unofficial community SDK to interact with the Algorand network, for Dart & Flutter
MIT License
36 stars 16 forks source link

Error when using applicationManager.applicationRepository.applicationService.getApplicationById #30

Closed jasonhtpham closed 2 years ago

jasonhtpham commented 2 years ago

I got this error:

I/flutter (16735): ┌───────────────────────────────────────────────────────────────────────────────
I/flutter (16735): │ type 'Null' is not a subtype of type 'int' in type cast
I/flutter (16735): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (16735): │ #0   _TokenDetailsViewState._submitPurchase
package:algo_uni_nft/…/token/tokenDetailsView.dart:838
I/flutter (16735): │ #1   <asynchronous suspension>
I/flutter (16735): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (16735): │ ⛔ Error message
I/flutter (16735): └───────────────────────────────────────────────────────────────────────────────

when I tried to use applicationManager.applicationRepository.applicationService.getApplicationById(myAppId). I check the package's code and found that the error might be caused by the type cast of the currentRound in:

ApplicationResponse _$ApplicationResponseFromJson(Map<String, dynamic> json) =>
    ApplicationResponse(
      currentRound: json['current-round'] as int, // This type cast here
      application: json['application'] == null
          ? null
          : Application.fromJson(json['application'] as Map<String, dynamic>),
    );
RootSoft commented 2 years ago

hi @jasonhtpham

Do you have an example query that I can use to simulate the request and test it out? Also please don't use the applicationManager.applicationRepository.applicationService directly, but rather use algorand.indexer().getApplicationById(applicationId) as applicationManager will be getting deprecated in the next version.

Kind regards, Tomas

jasonhtpham commented 2 years ago

Hi @RootSoft , thank you for your reply. That's helpful.

Also, when are you planning to release the new version, as the APIs will be deprecated soon (practically tomorrow). If you need help updating the package, please let me know, I will try to help out to the best ability. Cheers!

RootSoft commented 2 years ago

Should be fixed in v1.0.2. The API endpoints are reflected as well.