Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix stripe payment in flutter

Tags:

flutter

i have the issue on flutter_stripe_payment i am getting this error MissingPluginException (MissingPluginException(No implementation found for method setPublishableKey on channel stripe_payment))

  1. i have trid on MainActivity extend from FlutterActivity to FlutterFragmentActivity.
  2. i changing from minSdkVersion 16 to minSdkVersion 21 inside build.gradle in android > app
  3. i added ext.kotlin_version = '1.2.71' inside build.gradle in Android folder
    import 'package:app/UiHelper/AppBarHelper.dart';
    import 'package:app/UiHelper/ColorHelper.dart';
    import 'package:flutter/cupertino.dart';
    import 'package:flutter/material.dart';
    import 'package:stripe_payment/stripe_payment.dart';

    class MenuBookingScreen extends StatelessWidget {
       @override
       Widget build(BuildContext context) {
        return DrawWidget();
      }
    }

    class _ViewState extends State<DrawWidget> {
      @override
      void initState() {
        super.initState();
        initAction();
        // this part throw error while hot reload
        StripeSource.setPublishableKey("mykey");
      }

      initAction() async {}

      @override
      Widget build(BuildContext context) {
        return Scaffold(
            appBar: AppBarHelper().appBarGenerator(context),
            backgroundColor: ColorHelper().appBackground,
            body: Material(
                color: ColorHelper().appBody, child: uIDomElement(context)));
      }

      Widget uIDomElement(BuildContext context) {
        var _size = MediaQuery.of(context).size;
        return Container(
          width: _size.width,
          child: RaisedButton(
            color: Colors.indigo,
            textColor: Colors.white,
            disabledColor: Colors.grey,
            disabledTextColor: Colors.black,
            padding: EdgeInsets.all(13),
            splashColor: Colors.blueAccent,
            shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(5.0)),
            onPressed: () {
              // Add Card
            },
            child: Row(
              children: <Widget>[
                Icon(Icons.credit_card),
                SizedBox(
                  width: 15,
                ),
                Text("Add Card")
              ],
            ),
          ),
        );
      }
    }

    class DrawWidget extends StatefulWidget {
      @override
      _ViewState createState() => _ViewState();
    }
like image 223
jeremy Avatar asked Nov 16 '25 11:11

jeremy


1 Answers

Probably too late, but in case someone else bumps into this problem. 'flutter clean' did the trick for me..

like image 141
Heinrich Heine Avatar answered Nov 18 '25 21:11

Heinrich Heine



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!