Flutter stripe native payment crash

487 Views Asked by At

I'm trying to accept native apple payments in flutter, I've been following along at pubdev and built the examples over there. I've tried implementing the Native payment in my own app this way:

Scaffold(body: ListView(....),
  floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
      floatingActionButton: Container(
        width: 100,
        height: 100,
        child: FloatingActionButton(
            splashColor: Colors.red,
            backgroundColor: Colors.white,
            child: const Icon(
              Icons.payment,
              color: Colors.red,
              size: 50.0,
            ),
            onPressed: ()  async {
              Token paymentToken = await StripePayment.paymentRequestWithNativePay(
                androidPayOptions: null,
              applePayOptions: ApplePayPaymentOptions(
              countryCode: 'US',
              currencyCode: 'USD',
              items: [
              ApplePayItem(
              label: 'Test',
              amount: '13',
              )
              ],
              ));
              print(paymentToken.toString());
            }),
      )

The ListView has dynamically rendered Card widgets based on which items were selected. When I press the Floating action button to make a purchase the app crashes. I get this error:

Lost connection to device.
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23e3cf0e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50ba89b2 objc_exception_throw + 48
    2   UIKitCore                           0x00007fff485f256e -[UIViewController _presentViewController:withAnimationController:completion:] + 5218
    3   UIKitCore                           0x00007fff485f4a2e __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 98
    4   UIKitCore                           0x00007fff485f4f37 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
    5   UIKitCore                           0x00007fff485f498c -[UIViewController _presentViewController:animated:completion:] + 187
    6   UIKitCore                           0x00007fff485f4bf8 -[U<…>

I think my floating action button is getting in the way of the apple animation. I would like to keep the floating button there, it looks really nice. Any help would be Awesome, thanks!

1

There are 1 best solutions below

0
On

Bro try removing any other stripe library. I had the same problem, but had both

    stripe_native
    stripe_payment

So be deleting stripe_native my error resolved