Ad

Many Errors From Flutter_stripe Even After Changing MainActivity To FlutterFragmentActivity()

I'm using flutter_stripe package to handle payments in my app and as stated in the setup I've changed app/src/main/kotlin/MainActivity.kt from

class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }

to

class MainActivity: FlutterFragmentActivity() {
    override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
        GeneratedPluginRegistrant.registerWith(flutterEngine);
    }
}

but then when executing the series of operations in my button's on pressed I get a series of errors which I don't understand:

I/flutter (13121): Register card pressed
E/MethodChannel#flutter.stripe/payments(13121): Failed to handle method call
E/MethodChannel#flutter.stripe/payments(13121): android.view.InflateException: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Error inflating class com.google.android.material.textfield.TextInputLayout
E/MethodChannel#flutter.stripe/payments(13121): Caused by: android.view.InflateException: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Error inflating class com.google.android.material.textfield.TextInputLayout
E/MethodChannel#flutter.stripe/payments(13121): Caused by: java.lang.reflect.InvocationTargetException
E/MethodChannel#flutter.stripe/payments(13121):     at java.lang.reflect.Constructor.newInstance0(Native Method)
E/MethodChannel#flutter.stripe/payments(13121):     at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.createView(LayoutInflater.java:856)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1008)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.inflate(LayoutInflater.java:658)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
E/MethodChannel#flutter.stripe/payments(13121):     at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
E/MethodChannel#flutter.stripe/payments(13121):     at com.stripe.android.databinding.CardInputWidgetBinding.inflate(CardInputWidgetBinding.java:89)
E/MethodChannel#flutter.stripe/payments(13121):     at com.stripe.android.view.CardInputWidget.<init>(CardInputWidget.kt:62)
E/MethodChannel#flutter.stripe/payments(13121):     at com.stripe.android.view.CardInputWidget.<init>(CardInputWidget.kt:56)
E/MethodChannel#flutter.stripe/payments(13121):     at com.reactnativestripesdk.StripeSdkCardView.<init>(StripeSdkCardView.kt:35)
E/MethodChannel#flutter.stripe/payments(13121):     at com.reactnativestripesdk.StripeSdkCardViewManager.createViewInstance(StripeSdkCardViewManager.kt:58)
E/MethodChannel#flutter.stripe/payments(13121):     at com.reactnativestripesdk.StripeSdkCardViewManager.setCardDetails(StripeSdkCardViewManager.kt:86)
E/MethodChannel#flutter.stripe/payments(13121):     at com.flutter.stripe.StripeAndroidPlugin.onMethodCall(StripeAndroidPlugin.kt:123)
E/MethodChannel#flutter.stripe/payments(13121):     at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#flutter.stripe/payments(13121):     at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/MethodChannel#flutter.stripe/payments(13121):     at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/MethodChannel#flutter.stripe/payments(13121):     at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#flutter.stripe/payments(13121):     at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#flutter.stripe/payments(13121):     at android.os.Looper.loop(Looper.java:193)
E/MethodChannel#flutter.stripe/payments(13121):     at android.app.ActivityThread.main(ActivityThread.java:8059)
E/MethodChannel#flutter.stripe/payments(13121):     at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#flutter.stripe/payments(13121):     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
E/MethodChannel#flutter.stripe/payments(13121):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
E/MethodChannel#flutter.stripe/payments(13121): Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
E/MethodChannel#flutter.stripe/payments(13121):     at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:243)
E/MethodChannel#flutter.stripe/payments(13121):     at com.google.android.material.internal.ThemeEnforcement.checkAppCompatTheme(ThemeEnforcement.java:213)
E/MethodChannel#flutter.stripe/payments(13121):     at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:148)
E/MethodChannel#flutter.stripe/payments(13121):     at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:115)
E/MethodChannel#flutter.stripe/payments(13121):     at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:469)
E/MethodChannel#flutter.stripe/payments(13121):     at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:428)
E/MethodChannel#flutter.stripe/payments(13121):     ... 28 more
E/flutter (13121): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(error, Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Error inflating class com.google.android.material.textfield.TextInputLayout, null, android.view.InflateException: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Error inflating class com.google.android.material.textfield.TextInputLayout
E/flutter (13121): Caused by: android.view.InflateException: Binary XML file line #22 in com.vinny.fixit_cloud_biking:layout/card_input_widget: Error inflating class com.google.android.material.textfield.TextInputLayout
E/flutter (13121): Caused by: java.lang.reflect.InvocationTargetException
E/flutter (13121):  at java.lang.reflect.Constructor.newInstance0(Native Method)
E/flutter (13121):  at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
E/flutter (13121):  at android.view.LayoutInflater.createView(LayoutInflater.java:856)
E/flutter (13121):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1008)
E/flutter (13121):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963)
E/flutter (13121):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:1125)
E/flutter (13121):  at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1086)
E/flutter (13121):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:1128)
E/flutter (13121):  at android.view.LayoutInflater.inflate(LayoutInflater.java:658)
E/flutter (13121):  at android.view.LayoutInflater.inflate(LayoutInflater.java:536)
E/flutter (13121):  at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
E/flutter (13121):  at com.stripe.android.databinding.CardInputWidgetBinding.inflate(CardInputWidgetBinding.java:89)
E/flutter (13121):  at com.stripe.android.view.CardInputWidget.<init>(CardInputWidget.kt:62)
E/flutter (13121):  at com.stripe.android.view.CardInputWidget.<init>(CardInputWidget.kt:56)
E/flutter (13121):  at com.reactnativestripesdk.StripeSdkCardView.<init>(StripeSdkCardView.kt:35)
E/flutter (13121):  at com.reactnativestripesdk.StripeSdkCardViewManager.createViewInstance(StripeSdkCardViewManager.kt:58)
E/flutter (13121):  at com.reactnativestripesdk.StripeSdkCardViewManager.setCardDetails(StripeSdkCardViewManager.kt:86)
E/flutter (13121):  at com.flutter.stripe.StripeAndroidPlugin.onMethodCall(StripeAndroidPlugin.kt:123)
E/flutter (13121):  at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter (13121):  at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:84)
E/flutter (13121):  at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:865)
E/flutter (13121):  at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (13121):  at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter (13121):  at android.os.Looper.loop(Looper.java:193)
E/flutter (13121):  at android.app.ActivityThread.main(ActivityThread.java:8059)
E/flutter (13121):  at java.lang.reflect.Method.invoke(Native Method)
E/flutter (13121):  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:656)
E/flutter (13121):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:967)
E/flutter (13121): Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
E/flutter (13121):  at com.google.android.material.internal.ThemeEnforcement.checkTheme(ThemeEnforcement.java:243)
E/flutter (13121):  at com.google.android.material.internal.ThemeEnforcement.checkAppCompatTheme(ThemeEnforcement.java:213)
E/flutter (13121):  at com.google.android.material.internal.ThemeEnforcement.checkCompatibleTheme(ThemeEnforcement.java:148)
E/flutter (13121):  at com.google.android.material.internal.ThemeEnforcement.obtainTintedStyledAttributes(ThemeEnforcement.java:115)
E/flutter (13121):  at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:469)
E/flutter (13121):  at com.google.android.material.textfield.TextInputLayout.<init>(TextInputLayout.java:428)
E/flutter (13121):  ... 28 more
E/flutter (13121): )
E/flutter (13121): #0      JSONMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:164:7)
E/flutter (13121): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (13121): <asynchronous suspension>
E/flutter (13121): #2      MethodChannelStripe.dangerouslyUpdateCardDetails (package:stripe_platform_interface/src/method_channel_stripe.dart:221:5)
E/flutter (13121): <asynchronous suspension>
E/flutter (13121): #3      Stripe.dangerouslyUpdateCardDetails (package:flutter_stripe/src/stripe.dart:348:12)
E/flutter (13121): <asynchronous suspension>
E/flutter (13121): #4      _NewCardScreenState.build.<anonymous closure>.<anonymous closure> (package:fixit_cloud_biking/Screens/new_card_screen.dart:605:29)
E/flutter (13121): <asynchronous suspension>
E/flutter (13121): 

Did I miss to change or set anything else to use FlutterFragmentActivity()? Thank you very much. This is the whole code for the page:

class _NewCardScreenState extends State<NewCardScreen> {
  final GlobalKey<FormState> formKey = GlobalKey<FormState>();
  GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
  dynamic backButton = Platform.isIOS ? CupertinoIcons.back : Icons.arrow_back;
  CardDetails _card = CardDetails();

  Map<String, dynamic> jsonCard = {
    'type': 'card',
    'card': {
      'number': '',
      'exp_month': '',
      'exp_year': '',
      'cvc': '',
    },
  };

  PaymentMethod paymentMethod;
  String cardHolderName = '';
  bool isCvvFocused = false;
  bool useGlassMorphism = true;
  bool useBackgroundImage = false;

  @override
  void initState() {
    super.initState();
  }

  void update() => setState(() {});
  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(children: [
      Image(image: widget.bgImage.image, height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, fit: BoxFit.cover),
      BlocBuilder<PaymentBloc, PaymentState>(builder: (context, state) {
        print('∞∞∞∞∞ NewCardScreen state is: ${state.toString()}');
        // if (state is SetupIntentCreated) {
        //   if (_card.complete) {
        //     // var params = PaymentMethodParams.fromJson(_card.toJson());
        //     BillingDetails billingDetails = BillingDetails(
        //         name: widget.user.name,
        //         email: widget.user.email,
        //         phone: widget.user.phoneNumber,
        //         address: Address(
        //             city: widget.user.city,
        //             country: widget.user.country,
        //             postalCode: widget.user.zipCode,
        //             line1: widget.user.address,
        //             line2: 'null',
        //             state: 'null'));
        //     PaymentMethodParams paymentMethodParams =
        //         PaymentMethodParams.card(setupFutureUsage: PaymentIntentsFutureUsage.OnSession, billingDetails: billingDetails);
        //     BlocProvider.of<PaymentBloc>(context)
        //         .add(ConfirmSetupIntent(clientSecret: state.setupIntent.clientSecret, paymentMethodParams: paymentMethodParams));
        //   }
        // }
        // if (state is SetupIntentSucceeded) {
        //   Navigator.pop(context);
        // }
        // if (state is SetupIntentRequiresAction) {
        //   // // var si = Stripe.instance.handleCardAction(state.setupIntent.clientSecret);
        //   // if (_card.complete) {
        //   //   var params = PaymentMethodParams.fromJson(_card.toJson());
        //   //   BlocProvider.of<PaymentBloc>(context).add(ConfirmSetupIntent(clientSecret: state.setupIntent.clientSecret, paymentMethodParams: params));
        //   // }
        //   if (_card.complete) {
        //     // var params = PaymentMethodParams.fromJson(_card.toJson());
        //     BillingDetails billingDetails = BillingDetails(
        //         name: widget.user.name,
        //         email: widget.user.email,
        //         phone: widget.user.phoneNumber,
        //         address: Address(
        //             city: widget.user.city,
        //             country: widget.user.country,
        //             postalCode: widget.user.zipCode,
        //             line1: widget.user.address,
        //             line2: 'null',
        //             state: 'null'));
        //     PaymentMethodParams paymentMethodParams =
        //         PaymentMethodParams.card(setupFutureUsage: PaymentIntentsFutureUsage.OnSession, billingDetails: billingDetails);
        //     BlocProvider.of<PaymentBloc>(context)
        //         .add(ConfirmSetupIntent(clientSecret: state.setupIntent.clientSecret, paymentMethodParams: paymentMethodParams));
        //   }
        // }
        // if (state is SetupIntentRequiresPaymentMethod) {
        //   if (_card.complete) {
        //     var params = PaymentMethodParams.fromJson(_card.toJson());
        //     BlocProvider.of<PaymentBloc>(context).add(ConfirmSetupIntent(clientSecret: state.setupIntent.clientSecret, paymentMethodParams: params));
        //   }
        // }

        return Scaffold(
          key: scaffoldKey,
          backgroundColor: Colors.black.withAlpha(150),
          appBar: AppBar(
            elevation: 0,
            centerTitle: true,
            leading: IconButton(
                icon: Icon(backButton),
                color: Colors.redAccent,
                onPressed: () {
//                    cache.play('tableViewClose.mp3');
                  Navigator.pop(context);
                }),
            title: Text(
              AppLocalizations.instance.text('New card'),
              style: TextStyle(color: Colors.orange, fontSize: 22, fontWeight: FontWeight.w500, letterSpacing: 1),
            ),
            backgroundColor: Colors.transparent,
          ),
          body: Container(
            padding: EdgeInsets.all(10),
            child: Column(
              children: <Widget>[
                CreditCardWidget(
                  glassmorphismConfig: useGlassMorphism ? Glassmorphism.defaultConfig() : null,
                  cardNumber: jsonCard['card']['number'],
                  expiryDate: '${jsonCard['card']['exp_month']}/${jsonCard['card']['exp_year']}',
                  cardHolderName: cardHolderName,
                  cvvCode: jsonCard['card']['cvc'],
                  labelCardHolder: AppLocalizations.instance.text('Card holder'),
                  showBackView: isCvvFocused,
                  obscureCardNumber: false,
                  obscureCardCvv: false,
                  isHolderNameVisible: true,
                  cardBgColor: Colors.transparent,
                  backgroundImage: null,
                  isSwipeGestureEnabled: true,
                  onCreditCardWidgetChange: (CreditCardBrand creditCardBrand) {},
                ),
                Expanded(
                  // flex: 3,
                  child: SingleChildScrollView(
                    child: Column(
                      children: <Widget>[
                        /// CardField not focusing
                        // Padding(
                        //   padding: EdgeInsets.all(16),
                        //   child: CardField(
                        //     controller: controller,
                        //     style: TextStyle(fontSize: 20, color: Colors.white),
                        //     decoration: InputDecoration(
                        //       enabled: true,
                        //       isDense: true,
                        //       border: OutlineInputBorder(),
                        //       focusColor: Colors.orange,
                        //       focusedBorder: OutlineInputBorder(
                        //         borderSide: BorderSide(
                        //           color: Colors.orange,
                        //           width: 5,
                        //         ),
                        //       ),
                        //     ),
                        //     numberHintText: AppLocalizations.instance.text('Card number placeholder'),
                        //     expirationHintText: AppLocalizations.instance.text('Expiring date placeholder'),
                        //     cvcHintText: AppLocalizations.instance.text('Cvc placeholder'),
                        //     cursorColor: Colors.white,
                        //     // autofocus: true,
                        //     onFocus: (b) {},
                        //     onCardChanged: (card) {
                        //       setState(() {
                        //         _card = card;
                        //       });
                        //     },
                        //   ),
                        // ),

                        /// CardForm not showing up
                        // CardFormField(
                        //   controller: controller,
                        //   backgroundColor: Colors.redAccent,
                        // ),

                        /// CreditCardForm
                        CreditCardForm(
                          formKey: formKey,
                          obscureCvv: false,
                          obscureNumber: false,
                          cardNumber: jsonCard['card']['number'],
                          cvvCode: jsonCard['card']['cvc'],
                          isHolderNameVisible: true,
                          isCardNumberVisible: true,
                          isExpiryDateVisible: true,
                          cardHolderName: cardHolderName,
                          expiryDate: '${jsonCard['card']['exp_month']}/${jsonCard['card']['exp_year']}',
                          themeColor: Colors.redAccent,
                          textColor: Colors.white,
                          cursorColor: Colors.orange,
                          cardNumberDecoration: InputDecoration(
                            enabled: true,
                            isDense: true,
                            hintText: AppLocalizations.instance.text('Card number placeholder'),
                            hintStyle: TextStyle(fontSize: 15, color: Colors.grey[350]),
                            border: OutlineInputBorder(),
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.orange,
                                width: 2,
                              ),
                            ),
                            filled: true,
                            fillColor: Colors.white.withAlpha(60),
                          ),
                          expiryDateDecoration: InputDecoration(
                            enabled: true,
                            isDense: true,
                            hintText: AppLocalizations.instance.text('Expiring date placeholder'), //'nome',
                            hintStyle: TextStyle(fontSize: 15, color: Colors.grey[350]),
                            border: OutlineInputBorder(),
                            focusColor: Colors.lightGreenAccent,
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.orange,
                                width: 2,
                              ),
                            ),
                            filled: true,
                            fillColor: Colors.white.withAlpha(60),
                          ),
                          cvvCodeDecoration: InputDecoration(
                            isDense: true,
                            hintText: AppLocalizations.instance.text('Cvc placeholder'), //'nome',
                            hintStyle: TextStyle(fontSize: 15, color: Colors.grey[350]),
                            border: OutlineInputBorder(),
                            focusColor: Colors.lightGreenAccent,
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.orange,
                                width: 2,
                              ),
                            ),
                            filled: true,
                            fillColor: Colors.white.withAlpha(60),
                          ),
                          cardHolderDecoration: InputDecoration(
                            isDense: true,
                            hintText: AppLocalizations.instance.text('Card holder'),
                            hintStyle: TextStyle(fontSize: 15, color: Colors.grey[350]),
                            border: OutlineInputBorder(),
                            focusColor: Colors.lightGreenAccent,
                            focusedBorder: OutlineInputBorder(
                              borderSide: BorderSide(
                                color: Colors.orange,
                                width: 2,
                              ),
                            ),
                            filled: true,
                            fillColor: Colors.white.withAlpha(60),
                          ),
                          onCreditCardModelChange: (CreditCardModel cardData) {
                            setState(() {
                              isCvvFocused = cardData.isCvvFocused;
                              cardHolderName = cardData.cardHolderName;
                              jsonCard['card']['exp_month'] = cardData.expiryDate.split('/').first;
                              jsonCard['card']['exp_year'] = cardData.expiryDate.split('/').last;
                              jsonCard['card']['number'] = cardData.cardNumber;
                              jsonCard['card']['cvc'] = cardData.cvvCode;

                              print('exp month is ${cardData.expiryDate.split('/').first} and exp year is ${cardData.expiryDate.split('/').last}');

                              if (cardData.cardNumber != null) {
                                _card = _card.copyWith(number: cardData.cardNumber);
                              }

                              if (cardData.expiryDate.split('/').first != '') {
                                _card = _card.copyWith(expirationMonth: int.parse(cardData.expiryDate.split('/').first));
                              }
                              if (cardData.expiryDate.split('/').last != '') {
                                _card = _card.copyWith(expirationYear: int.parse(cardData.expiryDate.split('/').last));
                              }
                              if (cardData.cvvCode.isNotEmpty) {
                                _card = _card.copyWith(cvc: cardData.cvvCode);
                              }
                            });
                          },
                        ),
                        const SizedBox(
                          height: 20,
                        ),
                        // ResponseCard(
                        //   response: controller.details.toJson().toPrettyString(),
                        // )
                      ],
                    ),
                  ),
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    ElevatedButton.icon(
                        style: ButtonStyle(
                          elevation: MaterialStateProperty.all(0),
                          backgroundColor: MaterialStateProperty.all<Color>(Colors.orange),
                        ),
                        onPressed: () async {
                          print('Register card pressed');

                          if (jsonCard['card']['exp_month'] != '' &&
                              jsonCard['card']['exp_month'] != null &&
                              jsonCard['card']['exp_year'] != '' &&
                              jsonCard['card']['exp_year'] != null &&
                              jsonCard['card']['number'] != '' &&
                              jsonCard['card']['number'] != null &&
                              jsonCard['card']['cvc'] != '' &&
                              jsonCard['card']['cvc'] != null) {
                            await Stripe.instance.dangerouslyUpdateCardDetails(_card);
                            final billingDetails = BillingDetails(
                              email: widget.user.email,
                              phone: widget.user.phoneNumber,
                              address: Address(
                                city: widget.user.city,
                                country: AppLocalizations.instance.text('Country code'),
                                line1: widget.user.address,
                                line2: '',
                                state: '',
                                postalCode: widget.user.zipCode,
                              ),
                            );

                            paymentMethod = await Stripe.instance
                                .createPaymentMethod(PaymentMethodParams.card(
                              billingDetails: billingDetails,
                            ))
                                .then((value) {
                              print('Stripe.instance.createPaymentMethod : $value');
                            }).catchError((e) {
                              print('Stripe.instance.createPaymentMethod error: $e');
                            });


                            PaymentMethodParams params = PaymentMethodParams.cardFromMethodId(paymentMethodId: paymentMethod.id, cvc: _card.cvc);
                            BlocProvider.of<PaymentBloc>(context).add(CreateSetupIntent(paymentMethodParams: params));
                          }
                        },
                        icon: Icon(
                          Icons.payment,
                          color: Colors.white,
                        ),
                        label: Text(
                          AppLocalizations.instance.text('Register card'),
                          style: TextStyle(color: Colors.white, fontSize: 20),
                        )),
                  ],
                )
              ],
            ),
          ),
        );
      }),
    ]);
  }
}
Ad

Answer

After a painstaking code comparison with the example app I finally found the I was missing some code in my styles.xml in which I only had

<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">

so after changing it to below code it now works properly.

<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--    <style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">-->
    <style name="LaunchTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Show a splash screen on the activity. Automatically removed when
             Flutter draws its first frame -->
        <item name="android:windowBackground">@drawable/launch_background</item>
    </style>
    <style name="NormalTheme" parent="Theme.MaterialComponents">
        <item name="android:windowBackground">?android:colorBackground</item>
    </style>
</resources>

Hope it helps others. Cheers.

Ad
source: stackoverflow.com
Ad