Skip to main content
Use webview_flutter to embed frames in Flutter applications. The WebView communicates with your Dart code through JavaScript channels.
Read the manual integration overview for core concepts before you continue.

Setup

Dependencies

The examples below use cryptography for X25519 key exchange, but you can use any library that supports X25519 and AES-GCM. Add the required packages to your pubspec.yaml:
For platform-specific setup, add the implementation packages:
Run flutter pub get to install the packages.

Platform configuration

Add the following to your ios/Runner/Info.plist:

Key generation

Create a utility class for X25519 key generation and decryption:

Base WebView widget

Create a reusable widget for frame communication:

Handle JavaScript dialogs

In test mode, the Apple Pay frame renders a mock button and uses window.confirm to simulate the Apple Pay payment sheet (OK = success, Cancel = failed). webview_flutter does not surface window.confirm (or alert / prompt) by default — the underlying WKWebView on iOS and WebView on Android both require explicit dialog handlers. Without one, the call returns false with no UI shown, the frame interprets that as the customer cancelling, and every test transaction comes back with status: "failed". Wire dialog handling via the platform-specific implementations. On iOS use WebKitWebViewController’s UI delegate hooks; on Android use AndroidWebViewController to attach a WebChromeClient whose onJsConfirm returns the customer’s choice. Surface the prompt with a Flutter AlertDialog so it matches the rest of your UI, and call back into the controller with the result.
Wire dialog handling even if you only plan to ship live mode. It applies to any window.confirm, alert, or prompt the frame might surface, and makes test-mode debugging impossible without it.

Check frame

The check frame verifies whether a customer already has an active connection. It’s headless — no UI is rendered. Use it to skip the connect flow for returning customers. See check frame reference for event details.

Check widget

Usage


Connect frame

The connect frame establishes a customer connection to your application. See connect frame reference for event details.

Connect widget

Usage


Apple Pay frame

The Apple Pay frame renders the Apple Pay button and handles the payment flow. See Apple Pay frame reference for event details.
Apple Pay only works on iOS devices with Apple Pay configured.

Apple Pay widget

Usage


Google Pay frame

The Google Pay frame renders the Google Pay button and handles the payment flow. See Google Pay frame reference for event details.

Google Pay widget

Usage


Add Card frame

The add card frame lets a customer save a new card to their account. See add card frame reference for event details.

What you’ll need

Before you initialize the add card frame, you need:
  1. A clientToken from a successful connect flow

Add Card widget

Usage


Buy frame

The buy frame processes a card payment for a quote. It is headless — rendered at zero size — while the customer completes payment. If 3-D Secure is required, the frame emits a challenge event with a URL you open in a separate challenge frame. See buy frame reference for event details.

What you’ll need

Before you initialize the buy frame, you need:
  1. A clientToken from a successful connect flow
  2. A valid quote signature for the transaction

Buy widget

Challenge widget

Usage


Widget frame

For payment methods beyond Apple Pay — including credit/debit cards, Google Pay, bank transfers, and more — use the widget frame. It renders the full MoonPay buy experience inside a WebView, including payment-method selection and transaction confirmation. See pay with widget for a full walkthrough.

Widget widget

Usage