Poool Access - Flutter Plugin

The easiest way to add Poool Access to your Flutter app ✨

Description

Poool's flutter package allows to make a bridge between flutter applications and Poool Access solution accross common platforms (IOS & Android).

Installation

flutter pub add flutter_access

Requirements

  • Dart SDK >= 2.17.0 (not tested on older versions)
  • Flutter SDK >= 3.0.0 (not tested on older versions)
  • Provider plugin

Usage

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter_access/flutter_access.dart';

// Use the multiprovider component to combine Poool Access's provider with
// your existing ones
MultiProvider(
  providers: [
    // ... your providers
    ChangeNotifierProvider(
      create: (ref) => AccessProvider(
        appId: "Your App ID",
        debug: false,
      )
    ),
  ],
  // Somewhere in your app, use AccessWrapper to wrap your content and every Poool widgets
  child: AccessWrapper(
    appId: "Your App ID",
    children: [
      const Snippet(), // Your article preview
      const RestrictedContent(
        // Your complete article content
        child: YourPremiumContentWidget()
      ),
      // Load paywall from native library
      Paywall(
        config: { "cookies_enabled": true },
      ),
    ],
  ),
);

Documentation

<AccessProvider />

It uses the flutter provider plugin in order to use a global context to store access factories and events, with some listeners. It has to be created through a ChangeNotifierProvider.

Props

  • appId {String} Your Poool App ID
  • debug {Boolean} Enable / Disable logs

<AccessWrapper />

It is used to wrap your content (both previews and complete premium articles) with Poool widgets.

Props

  • appId {String} Your Poool App ID (it obviously has to be the same used for AccessProvider)
  • children {List<Widgets>} A list of flutter widgets

<Snippet />

Use it to display your preview or free content, which will be displayed above Poool Access's Paywall.

Props

  • child {Widget} Free content or article's preview

<RestrictedContent />

Use it to display your article's premium content, when the paywall is finally released.

Props

  • child {Widget} Premium content

<Paywall />

Used to load and display Poool's Paywall from native side (ios/android)

Props

  • pageType {String} (optional, default: 'premium') Current page type (supported types: page, premium, free)
  • config {Map<String, Object>} (optional) Paywall config (see the configuration documentation).
  • styles {Map<String, Object>} (optional) Paywall styles (see the styles documentation).
  • texts {Map<String, String>} (optional) Paywall texts (see the texts documentation).
  • variables {Map<String, Object>} (optional) Paywall variables (see the variables documentation).
  • events {Map<String, Function} (optional) Event listeners (see the events documentation).
  • disableViewLoader {Boolean} (optional, default: false) Disables the default view loader (circle progress indicator)
  • customViewLoader {Widget} (optional) Choose your own custom view loader to replace the default one if view loader is still enabled
  • releaseOnError {Boolean} (optional, default: false) Choose between releasing the entire article when Poool is enable to fetch your paywall & config, or keep fully blocking the entire content in RestrictedContent widget.

<AccessBottomSheet />

This widget can be used anywhere and doesnt need to be wrapped in a AccessWrapper widget. Instead of being displayed in the article, it will bring the Paywall in a native bottom sheet, locking access to your entire app. It barely has the same props than Paywall widget. Since AccessWrapper isn't needed here, don't forget to bring your appId.

Props

  • appId {String} Your Poool App ID
  • pageType {String} (optional, default: 'premium') Current page type (supported types: page, premium, free)
  • config {Map<String, Object>} (optional) Paywall config (see the configuration documentation).
  • styles {Map<String, Object>} (optional) Paywall styles (see the styles documentation).
  • texts {Map<String, String>} (optional) Paywall texts (see the texts documentation).
  • variables {Map<String, Object>} (optional) Paywall variables (see the variables documentation).
  • events {Map<String, Function} (optional) Event listeners (see the events documentation).
  • releaseOnError {Boolean} (optional, default: false) Choose between releasing the entire article when Poool is enable to fetch your paywall & config, or keep fully blocking the entire content in RestrictedContent widget.

Contributing

Please check the CONTRIBUTING.md doc for contribution guidelines.

Development

Install dependencies:

flutter pub get

(Optional-iOS Only) Install pods:

cd example/ios && pod install

To run example, go to Android Studio or XCode and launch with your prefered device or emulator. From project root directory run:

cd example && flutter devices

Then select from this list the device you want and:

or

flutter run -d your_device

where your_device is the name or id found in the list you get in the step before

License

This software is licensed under MIT.