WebEferen / flutter_wallet_card

Flutter Wallet Card plugin (iOS & Android)
MIT License
12 stars 22 forks source link

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

Open elninho22 opened 8 months ago

elninho22 commented 8 months ago

error when adding/testing official apple examples wallets, I receive the following error:

Can you help me please, thank you very much.

example pkpass attachment

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'int' is not a subtype of type 'String'

0 new PasskitField.fromJson (package:flutter_wallet_card/models/PasskitField.dart:29:18)

1 new PasskitStructure.fromJson. (package:flutter_wallet_card/models/PasskitStructure.dart:47:37)

2 MappedListIterable.elementAt (dart:_internal/iterable.dart:425:31)

3 ListIterator.moveNext (dart:_internal/iterable.dart:354:26)

4 new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:189:27)

5 new _GrowableList.of (dart:core-patch/growable_array.dart:150:28)

6 new List.of (dart:core-patch/array_patch.dart:39:18)

7 ListIterable.toList (dart:_internal/iterable.dart:224:7)

8 new PasskitStructure.fromJson (package:flutter_wallet_card/models/PasskitStructure.dart:48:12)

9 PasskitPass._structure (package:flutter_wallet_card/models/PasskitPass.dart:229:50)

10 new PasskitPass.fromJson (package:fl<…>

----- flutter logs ------

Flutter (Channel stable, 3.19.2, on macOS 14.3.1 23D60 darwin-arm64, locale pt-BR) • Flutter version 3.19.2 on channel stable at /Users/andrejuliano/fvm/versions/3.19.2 ! Warning: dart on your path resolves to /opt/homebrew/Cellar/dart/2.17.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/andrejuliano/fvm/versions/3.19.2. Consider adding /Users/andrejuliano/fvm/versions/3.19.2/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 7482962148 (2 weeks ago), 2024-02-27 16:51:22 -0500 • Engine revision 04817c99c9 • Dart version 3.3.0 • DevTools version 2.31.1 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) • Android SDK at /Users/andrejuliano/Library/Android/sdk • Platform android-34, build-tools 34.0.0 • ANDROID_HOME = /Users/andrejuliano/Library/Android/sdk • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15C500b • CocoaPods version 1.15.2

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • android-studio-dir = /Applications/Android Studio.app • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] VS Code (version 1.87.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.84.0

[✓] Connected device (5 available) • Mi A3 (mobile) • 7e191bc32589 • android-arm64 • Android 11 (API 30) • iPhone (mobile) • 00008030-000D15E23A32802E • ios • iOS 17.3.1 21D61 • iPhone 15 Pro (mobile) • 1C3A6CDD-2D15-42B2-A1E7-15875240E0AC • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.3.1 23D60 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 122.0.6261.112

[✓] Network resources • All expected network resources are available.

! Doctor found issues in 1 category. Generic.pkpass.zip

WebEferen commented 7 months ago

Hi @elninho22,

Will take a look at it - looks like Apple has changes some properties for the passkit. I need to reflect those changes :)

timmaffett commented 5 months ago

You need to change PasskitFIeld.dart 's fromJson() method to something like this:

  factory PasskitField.fromJson(Map<String, dynamic> json) {
    return PasskitField(
      key: json['key']?.toString() ?? '',
      value: json['value']?.toString() ?? '',
      label: json['label']?.toString(),
      changeMessage: json['changeMessage']?.toString(),
    );
  }

when to make sure types (like int in your case) get promoted to a String. The fields that can't be null also need to have the ?? '' appended so that a default String value is provided.

I have just started trying this package out, but I will most likely be providing a PR to address this and any other issues I find.

WebEferen commented 5 months ago

Great @timmaffett Unfortunately I don't have enough time to tackle issues due to limited availability. Would be awesome to get some help in order to keep library up-to-date ☺️