Flutter SDK

Installation

The Flutter plugin for Link is a wrapper for the native Android and iOS SDKs. You can install it from Pinwheel's pub.dev page.

See the included example app for a working demo.

  1. Add the depenedency to pubspec.yaml.

You can use pub.dev:

dependencies:
  pinwheel: ^3.1.0

You can also use git:

dependencies:
  pinwheel:
      git:
        url: git://github.com/underdog-tech/pinwheel-flutter-sdk.git
        ref: main
  1. Import the Pinwheel widget, and models.
import 'package:pinwheel/models.dart';
import 'package:pinwheel/pinwheel.dart';

Build requirements

Android

  • Android minSdkVersion: API 22 or higher.
  • Android compileSdkVersion: API 34 or higher.

iOS

  • Deployment target: iOS 13.0 or greater.

Usage

  1. Implement any optional callbacks.

Details for the callbacks, and model objects can be found in the lib/models.dart, and lib/pinwheel.dart files. You can read more about Link events to see all available events.

_onExit(PinwheelExitPayload? payload) {
  print(payload);
  Navigator.pop(context);
}

_onEvent(String name, PinwheelEventPayload? payload) {
  print(payload);
}

_onError(PinwheelError error) {
  print(error);
}

_onSuccess(PinwheelSuccessPayload payload) {
  print(payload);
}

_onLogin(PinwheelLoginPayload payload) {
  print(payload);
}
  1. Fetch the Link token from your server.

Follow the getting started guide for details on Link tokens and modal initialization.

  1. Optional: Use Dark Mode

If your app implements a dark mode, get your dark mode value from your app logic (whatever determines whether your app is in dark mode). Use that in the following initialization.

  1. Initialize the PinwheelLink StatefulWidget.
PinwheelLink link = PinwheelLink(
  token: payload.token, 
  onExit: _onExit,
  onError: _onError, 
  onEvent: _onEvent,
  onSuccess: _onSuccess,
  onLogin: _onLogin,
	useDarkMode: _isDarkMode, // If you use dark mode, set this
);
  1. Show the widget

PinwheelLink is a StatefulWidget that you can display and hide in your app's view hierarchy.

Note: until the PinwheelLink StatefulWidget is instantiated with a link token, it will remain idle (no background threads, network requests, or analytics are performed).

🎉 You're done! You're now ready to test and go live.


What’s Next