pikaju / flutter-braintree

Flutter plugin that wraps the native Braintree SDKs. Enables payments with credit cards, PayPal, Google Pay and more.
https://pub.dev/packages/flutter_braintree
MIT License
64 stars 119 forks source link

Does it support FLUTTER WEB or any future plans to support web? #55

Closed PaulD1980 closed 3 years ago

PaulD1980 commented 3 years ago

Does it support FLUTTER WEB or any future plans to support web?

pikaju commented 3 years ago

I don't have any plans as of right now, but pull requests are always welcome. Duplicate of #21.

Babwenbiber commented 2 years ago

For anyone still being interested in this... I digged into the braintree docs and found some easy solution which works at least for creditcards.

  1. create static file (e.g. in assets/html/index.html)
  2. My content looks like this, but note that you can style it the way you want it:
    
    <script src="https://js.braintreegateway.com/web/dropin/1.33.0/js/dropin.js"></script>

3.  Call this code from flutter and with the listener you can handle the none.

import 'dart:html' as html; import 'dart:js' as js; import 'dart:ui' as ui;

import 'package:flutter/material.dart';

const String viewID = "your-view-id";

class HtmlTryPage extends StatefulWidget { const HtmlTryPage({Key? key}) : super(key: key);

@override State createState() => _HtmlTryPageState(); }

class _HtmlTryPageState extends State { @override void initState() { super.initState(); html.window.addEventListener("message", (html.Event event) { var data = (event as html.MessageEvent).data;

  print(data);
});

}

@override Widget build(BuildContext context) { // ignore: undefined_prefixed_name ui.platformViewRegistry.registerViewFactory( viewID, (int id) => html.IFrameElement() ..width = MediaQuery.of(context).size.width.toString() ..height = MediaQuery.of(context).size.height.toString() ..src = 'assets/html/index.html' ..style.border = 'none');

return const SizedBox(
  height: 500,
  child: HtmlElementView(
    viewType: viewID,
  ),
);

} }


Hope this helps someone :)