braintree 0.1.2

Braintree for Flutter #

A Flutter plugin that wraps the native Braintree Drop-In UI SDKs. Currently only supports Android.

Installation #

Add braintree to your pubspec.yaml file:

  braintree: ^0.1.2

Android #

As of version 0.1.0, you must migrate to AndroidX.
In /app/build.gradle, set your minSdkVersion to at least 21.

PayPal / Venmo #

In order for your drop-in to support PayPal or Venmo payments, you must allow for the browser switch by adding an intent filter to your AndroidManifest.xml (inside the <application> body):

<activity android:name="com.braintreepayments.api.BraintreeBrowserSwitchActivity"
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="${applicationId}.braintree" />

Important: Your app's URL scheme must begin with your app's package ID and end with .braintree. For example, if the Package ID is com.your-company.your-app, then your URL scheme should be com.your-company.your-app.braintree. ${applicationId} is automatically applied with your app's package when using Gradle. Note: The scheme you define must use all lowercase letters. If your package contains underscores, the underscores should be removed when specifying the scheme in your Android Manifest.

Google Pay #

Add the wallet enabled meta-data tag to your AndroidManifest.xml:

<meta-data android:name="" android:value="true"/>

Usage #

Import the plugin:

import 'package:braintree/braintree.dart';

Create a drop-in request object:

var request = BraintreeDropInRequest(
  clientToken: '<Insert your client token here>'
  collectDeviceData: true,
  googlePaymentRequest: BraintreeGooglePaymentRequest(
    totalPrice: '4.20',
    currencyCode: 'USD',
    billingAddressRequired: false,
  paypalRequest: BraintreePayPalRequest(
    amount: '4.20',
    displayName: 'Example company',

Then launch the drop-in:

BraintreeDropInResult result = await BraintreeDropIn.start(request);

Access the payment nonce:

if (result != null) {
  print('Nonce: ${result.paymentMethodNonce.nonce}');
} else {
  print('Selection was canceled.');

See BraintreeDropInRequest and BraintreeDropInResult for more documentation.

0.1.2 #

  • Switch to Android SDK version 4.1.1 (this includes a fix for the Google Payment issue)
  • Tweak example code slightly

0.1.1 #

  • Minor improvements

0.1.0 #

  • Migrate to AndroidX
  • Completely overhaul the API to more closely resemble the native Android Drop-in API
  • Add support for Google Pay (may not work properly yet)
  • Add credit card scanning with

0.0.2 #

  • Improve
  • Add analysis_options.yaml
  • Remove unnecessary dependency in the example build.gradle file

0.0.1 #

  • Add basic Drop-in UI functionality for Android


Braintree example project #

Demonstrates how to use the braintree plugin.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  braintree: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:braintree/braintree.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Sep 13, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies