i'm having some truble in Flutter.
flutter doctor -v
output:
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-x64, locale en-IT)
• Flutter version 2.5.1 at /Users/me/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffb2ecea52 (6 days ago), 2021-09-17 15:26:33 -0400
• Engine revision b3af521a05
• Dart version 2.14.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/me/Library/Android/sdk
• Platform android-30, build-tools 29.0.3
• Java binary at: /Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.11.2
[✓] Android Studio (version 4.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
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.60.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.26.0
[✓] Connected device (1 available)
• SM G930F (mobile) • android-arm64 • Android 8.0.0 (API 26)
• No issues found!
I have recently updated and migrated my code to null safety and updated all the dependencies; since I do this, I have some problems with the in_app_purchase
package version 1.0.8 (https://pub.dev/packages/in_app_purchase).
When i run the app on Android device (iOS devices works) i got an error:
Unhandled Exception: type 'int' is not a subtype of type 'String?' in type cast
while calling:
ProductDetailsResponse response = await InAppPurchase.instance.queryProductDetails({'MY_PRODUCT_ID'});
Right after the function got called, VSCode show me that the error happen in the sku_details_wrapper.g.dart
file into the function that convert the json to SkuDetailsWrapper
:
SkuDetailsWrapper _$SkuDetailsWrapperFromJson(Map json) {
return SkuDetailsWrapper(
description: json['description'] as String? ?? '',
freeTrialPeriod: json['freeTrialPeriod'] as String? ?? '',
introductoryPrice: json['introductoryPrice'] as String? ?? '',
introductoryPriceMicros: json['introductoryPriceAmountMicros'] as String? ?? '',
introductoryPriceCycles: json['introductoryPriceCycles'] as int? ?? 0,
introductoryPricePeriod: json['introductoryPricePeriod'] as String? ?? '',
price: json['price'] as String? ?? '',
priceAmountMicros: json['priceAmountMicros'] as int? ?? 0,
priceCurrencyCode: json['priceCurrencyCode'] as String? ?? '',
priceCurrencySymbol: json['priceCurrencySymbol'] as String? ?? '',
sku: json['sku'] as String? ?? '',
subscriptionPeriod: json['subscriptionPeriod'] as String? ?? '',
title: json['title'] as String? ?? '',
type: const SkuTypeConverter().fromJson(json['type'] as String?),
originalPrice: json['originalPrice'] as String? ?? '',
originalPriceAmountMicros: json['originalPriceAmountMicros'] as int? ?? 0,
);
}
In particular the error line is:
introductoryPriceMicros: json['introductoryPriceAmountMicros'] as String? ?? '',
where it try to convert an int (json['introductoryPriceAmountMicros']
) to a String?
.
Can you help me please? I'm not able to find any help online.