After upgrading our Flutter environment from version 3.13.8 to 3.19.3, we encountered a persistent error when fetching offerings from RevenueCat using the purchases_flutter plugin. The application throws a type cast exception, specifically type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast, during the offerings fetch operation.
 
Details
- Flutter Version: Upgraded from 3.13.8 to 3.19.3.
 purchases_flutterVersion: Initially encountered on version 6.21.0; upgraded to 6.24.0 in an attempt to resolve the issue, but the error persists.- Error Message: 
type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast - Error Location: The error occurs within the 
try-catchblock around thePurchases.getOfferings()call, indicating an issue with handling the fetched offerings data. - Observations:	
- The debug logs indicate that the 
getOfferingscall successfully contacts RevenueCat and receives a response, but fails during JSON deserialization or handling within the plugin. - The issue arose immediately following the Flutter upgrade.
 
 - The debug logs indicate that the 
 
Code
1Future<void> updateAvailablePlans() async {2    _logVerboseLevelMessage('Updating Available Plans');3    purchasesUpdating.value = true;45    Offerings? offerings;6    try {7      _logVerboseLevelMessage('Getting Offerings from RevenueCat');8      offerings = await Purchases.getOfferings();9      _logVerboseLevelMessage('Offerings: $offerings');10    } on PlatformException catch (e) {11      debugPrint('Offerings Error: $e');12      Get.customSnackBar(13        status: StatusType.error,14        compact: true,15        title: e.message ?? 'Unknown error',16      );17      allAvailablePlans.clear();18      return;19    } catch (e) {20      _logErrorLevelMessage('Error getting Offerings: $e', e, null);21      Get.customSnackBar(22        status: StatusType.error,23        compact: true,24        title: e.toString(),25      );26      allAvailablePlans.clear();27      return;28    }2930    purchasesUpdating.value = false;3132    // .... Rest of the code33  }
Logs
1D/[Purchases] - DEBUG(25790): ℹ️ Debug logging enabled2D/[Purchases] - DEBUG(25790): ℹ️ SDK Version - 7.5.23D/[Purchases] - DEBUG(25790): ℹ️ Package name - com.deepklarity.storia4D/[Purchases] - DEBUG(25790): 👤 Initial App User ID: {Omitted}5D/[Purchases] - DEBUG(25790): ℹ️ Purchases configured with response verification: DISABLED6D/[Purchases] - DEBUG(25790): 👤 Identifying App User ID: {Omitted}7D/[Purchases] - DEBUG(25790): ℹ️ Deleting old synced subscriber attributes that don't belong to {Omitted}8D/[Purchases] - DEBUG(25790): ℹ️ App foregrounded9D/[Purchases] - DEBUG(25790): ℹ️ CustomerInfo cache is stale, updating from network in foreground.10D/[Purchases] - DEBUG(25790): Retrieving customer info with policy: FETCH_CURRENT11D/[Purchases] - DEBUG(25790): ℹ️ Updating pending purchase queue12D/[Purchases] - DEBUG(25790): ℹ️ Offerings cache is stale, updating from network in foreground13D/[Purchases] - DEBUG(25790): 😻 Start Offerings update from network.14D/[Purchases] - DEBUG(25790): ℹ️ Querying purchases15D/[Purchases] - DEBUG(25790): Request already scheduled with jitter delay, adding existing callbacks to unjittered request with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/{Omitted}/offerings], appInBackground=false)16D/[Purchases] - DEBUG(25790): ℹ️ Updating pending purchase queue17D/[Purchases] - DEBUG(25790): ℹ️ No subscriber attributes to synchronize.18D/[Purchases] - DEBUG(25790): ℹ️ Listener set19D/[Purchases] - DEBUG(25790): ℹ️ Sending latest CustomerInfo to listener.20D/[Purchases] - DEBUG(25790): ℹ️ Starting connection for com.android.billingclient.api.BillingClientImpl@af4104a21D/[Purchases] - DEBUG(25790): ℹ️ Ending connection for com.android.billingclient.api.BillingClientImpl@228549922D/[Purchases] - DEBUG(25790): ℹ️ Billing Service Setup finished for com.android.billingclient.api.BillingClientImpl@af4104a23D/[Purchases] - DEBUG(25790): ℹ️ Updating pending purchase queue24D/[Purchases] - DEBUG(25790): Retrieving customer info with policy: CACHED_OR_FETCHED25D/[Purchases] - DEBUG(25790): ℹ️ Vending CustomerInfo from cache.26D/[Purchases] - DEBUG(25790): ℹ️ Checking if cache is stale AppInBackground false27D/[Purchases] - DEBUG(25790): ℹ️ Syncing purchases28D/[Purchases] - DEBUG(25790): ℹ️ Querying purchase history for type subs29D/[Purchases] - DEBUG(25790): ℹ️ Cleaning previously sent tokens30D/[Purchases] - DEBUG(25790): ℹ️ Tokens already posted: []31D/[Purchases] - DEBUG(25790): ℹ️ Saving tokens []32D/[Purchases] - DEBUG(25790): ℹ️ Tokens already posted: []33D/[Purchases] - DEBUG(25790): ℹ️ No pending purchases to sync34D/[Purchases] - DEBUG(25790): Request already scheduled with jitter delay, adding existing callbacks to unjittered request with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/{Omitted}], appInBackground=false)35D/[Purchases] - DEBUG(25790): Retrieving customer info with policy: CACHED_OR_FETCHED36D/[Purchases] - DEBUG(25790): ℹ️ Vending CustomerInfo from cache.37D/[Purchases] - DEBUG(25790): ℹ️ Checking if cache is stale AppInBackground false38D/[Purchases] - DEBUG(25790): ℹ️ No cached Offerings, fetching from network39D/[Purchases] - DEBUG(25790): 😻 Start Offerings update from network.40D/[Purchases] - DEBUG(25790): Same call already in progress, adding to callbacks map with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/{Omitted}/offerings], appInBackground=false)41D/[Purchases] - DEBUG(25790): Request already scheduled with jitter delay, adding existing callbacks to unjittered request with key: BackgroundAwareCallbackCacheKey(cacheKey=[/subscribers/{Omitted}/offerings], appInBackground=false)42D/[Purchases] - DEBUG(25790): Billing connected with country code: IN43D/TrafficStats(25790): tagSocket(225) with statsTag=0xffffffff, statsUid=-144W/WindowOnBackDispatcher(25790): OnBackInvokedCallback is not enabled for the application.45W/WindowOnBackDispatcher(25790): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.46D/[Purchases] - DEBUG(25790): API request started: GET /subscribers/{Omitted}/offerings47D/[Purchases] - DEBUG(25790): API request completed with status: GET /subscribers/{Omitted}/offerings 30448249D/[Purchases] - DEBUG(25790): ℹ️ Requesting products from the store with identifiers: storia_premium, storia_topup_con_19950251D/[Purchases] - DEBUG(25790): ℹ️ Querying purchases52D/[Purchases] - DEBUG(25790): ℹ️ Cleaning previously sent tokens53D/[Purchases] - DEBUG(25790): ℹ️ Tokens already posted: []54D/[Purchases] - DEBUG(25790): ℹ️ Saving tokens []55D/[Purchases] - DEBUG(25790): ℹ️ Tokens already posted: []56D/[Purchases] - DEBUG(25790): ℹ️ No pending purchases to sync57D/[Purchases] - DEBUG(25790): ℹ️ Cleaning previously sent tokens58D/[Purchases] - DEBUG(25790): ℹ️ Tokens already posted: []59D/[Purchases] - DEBUG(25790): ℹ️ Saving tokens []60D/[Purchases] - DEBUG(25790): ℹ️ Tokens already posted: []61D/[Purchases] - DEBUG(25790): ℹ️ No pending purchases to sync62D/[Purchases] - DEBUG(25790): ℹ️ Products request finished for storia_premium, storia_topup_con_19963D/[Purchases] - DEBUG(25790): ℹ️ Requesting products from the store with identifiers: storia_topup_con_19964D/[Purchases] - DEBUG(25790): ℹ️ Products request finished for storia_topup_con_19965D/[Purchases] - DEBUG(25790): 💰 Retrieved productDetailsList: ProductDetails{jsonString='{"productId":"storia_topup_con_199","type":"inapp","title":"TopUp (Storia - AI generated stories)","name":"TopUp","description":"TopUp","localizedIn":["en-US"],"skuDetailsToken":"AEuhp4JGY4oM_SKIBDBFHhLlW741aOpnE0ho-4WBrg6sV2zuuAMgxsSjQ3rMm-iz0BM=","oneTimePurchaseOfferDetails":{"priceAmountMicros":180000000,"priceCurrencyCode":"INR","formattedPrice":"₹180.00"}}', parsedJson={"productId":"storia_topup_con_199","type":"inapp","title":"TopUp (Storia - AI generated stories)","name":"TopUp","description":"TopUp","localizedIn":["en-US"],"skuDetailsToken":"AEuhp4JGY4oM_SKIBDBFHhLlW741aOpnE0ho-4WBrg6sV2zuuAMgxsSjQ3rMm-iz0BM=","oneTimePurchaseOfferDetails":{"priceAmountMicros":180000000,"priceCurrencyCode":"INR","formattedPrice":"₹180.00"}}, productId='storia_topup_con_199', productType='inapp', title='TopUp (Storia - AI generated stories)', productDetailsToken='AEuhp4JGY4oM_SKIBDBFHhLlW741aOpnE0ho-4WBrg6sV2zuuAMgxsSjQ3rMm-iz0BM=', subscriptionOfferDetails=null}66267D/[Purchases] - DEBUG(25790): 💰 storia_topup_con_199 - ProductDetails{jsonString='{"productId":"storia_topup_con_199","type":"inapp","title":"TopUp (Storia - AI generated stories)","name":"TopUp","description":"TopUp","localizedIn":["en-US"],"skuDetailsToken":"AEuhp4JGY4oM_SKIBDBFHhLlW741aOpnE0ho-4WBrg6sV2zuuAMgxsSjQ3rMm-iz0BM=","oneTimePurchaseOfferDetails":{"priceAmountMicros":180000000,"priceCurrencyCode":"INR","formattedPrice":"₹180.00"}}', parsedJson={"productId":"storia_topup_con_199","type":"inapp","title":"TopUp (Storia - AI generated stories)","name":"TopUp","description":"TopUp","localizedIn":["en-US"],"skuDetailsToken":"AEuhp4JGY4oM_SKIBDBFHhLlW741aOpnE0ho-4WBrg6sV2zuuAMgxsSjQ3rMm-iz0BM=","oneTimePurchaseOfferDetails":{"priceAmountMicros":180000000,"priceCurrencyCode":"INR","formattedPrice":"₹180.00"}}, productId='storia_topup_con_199', productType='inapp', title='TopUp (Storia - AI generated stories)', productDetailsToken='AEuhp4JGY4oM_SKIBDBFHhLlW741aOpnE0ho-4WBrg6sV2zuuAMgxsSjQ3rMm-iz0BM=', subscriptionOfferDetails=null}6869D/[Purchases] - DEBUG(25790): ℹ️ Building offerings response with 2 products70I/flutter (25790): ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────71I/flutter (25790): │ type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast72I/flutter (25790): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄73I/flutter (25790): │ #0   LoggerHelper.logErrorLevelMessage (package:storia/logic/services/misc_helpers/logger_helper.dart:33:13)74I/flutter (25790): │ #1   PurchasesHelper._logErrorLevelMessage (package:storia/logic/services/purchases_helpers/purchases_helper.dart:386:10)75I/flutter (25790): │ #2   PurchasesHelper.updateAvailablePlans (package:storia/logic/services/purchases_helpers/purchases_helper.dart:309:7)76I/flutter (25790): │ #3   <asynchronous suspension>77I/flutter (25790): │ #4   PurchasesHelper._customerUpdateListener (package:storia/logic/services/purchases_helpers/purchases_helper.dart:63:5)78I/flutter (25790): │ #5   <asynchronous suspension>79I/flutter (25790): ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄80I/flutter (25790): │ ⛔ Error getting Offerings: type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast81I/flutter (25790): └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────82D/[Purchases] - DEBUG(25790): API request started: GET /subscribers/6VhC9mt2AFYPWg7puz2nqnzrbqR283D/[Purchases] - DEBUG(25790): API request completed with status: GET /subscribers/6VhC9mt2AFYPWg7puz2nqnzrbqR2 30484D/[Purchases] - DEBUG(25790): 😻 CustomerInfo updated from network.85D/[Purchases] - DEBUG(25790): ℹ️ Purchase history is empty.86D/[Purchases] - DEBUG(25790): ℹ️ Querying purchase history for type inapp87D/[Purchases] - DEBUG(25790): ℹ️ Purchase history is empty.88D/[Purchases] - DEBUG(25790): Retrieving customer info with policy: CACHED_OR_FETCHED89D/[Purchases] - DEBUG(25790): ℹ️ Vending CustomerInfo from cache.90D/[Purchases] - DEBUG(25790): ℹ️ Checking if cache is stale AppInBackground false91D/ScrollOptim [SceneManager](25790): updateCurrentActivity: mCurrentActivityName=null, isOptEnable=true, isAnimAheadEnable=true, isFrameInsertEnable=true, InsertNum=1, isEnabledForScrollChanged=false

