Skip to content

type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast #2360

@KenilDiyora

Description

@KenilDiyora

Describe the bug

Calling Stripe.instance.collectBankAccount() successfully opens and completes the Stripe bank account collection UI, but after the flow finishes the Flutter app throws a runtime exception:

type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

The exception appears to originate from ResultParser.parseError inside the stripe_platform_interface.

This occurs even though the bank account linking flow completes successfully.


To Reproduce

Steps to reproduce the behavior:

  1. Call Stripe.instance.collectBankAccount() with a valid clientSecret from the backend.
  2. Complete the Stripe bank account collection UI.
  3. After completion, the following exception is thrown.

Example code

    final result = await Stripe.instance.collectBankAccount(
      clientSecret: model.clientSecret ?? '',
      isPaymentIntent: false,
      params: CollectBankAccountParams(
        paymentMethodType: PaymentMethodType.USBankAccount,
        paymentMethodData: CollectBankAccountPaymentMethodData(
          billingDetails: BillingDetails(
            name: user?.getName(),
            email: user?.email,
          ),
        ),
      ),
    );

Exception

flutter: type 'Null' is not a subtype of type 'Map<String, dynamic>' in type cast

#0      _$StripeExceptionFromJson (package:stripe_platform_interface/src/models/errors.g.dart:26:23)
#1      new StripeException.fromJson (package:stripe_platform_interface/src/models/errors.dart:44:7)
#2      ResultParser.parseError (package:stripe_platform_interface/src/result_parser.dart:21:28)
#3      ResultParser.parse (package:stripe_platform_interface/src/result_parser.dart:16:13)
#4      MethodChannelStripe.collectBankAccount (package:stripe_platform_interface/src/method_channel_stripe.dart:590:7)
<asynchronous suspension>
#5      Stripe.collectBankAccount (package:flutter_stripe/src/stripe.dart:641:12)
<asynchronous suspension>

Expected behavior

collectBankAccount() should complete without throwing an exception when the bank account collection flow finishes successfully.


Smartphone / tablet

  • Device: iOS Simulator and real iOS device (likely reproducible on Android as well)
  • OS: iOS (tested on simulator and real device)
  • Package version: flutter_stripe: ^12.3.0
  • Flutter version: 3.35.3

Additional context

  • The bank account collection UI works correctly.
  • The exception occurs after the UI flow completes.
  • This seems related to ResultParser.parseError attempting to parse a null error object into Map<String, dynamic>.

✅ This issue might be caused by null error handling in the platform interface when no error object is returned from native code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions