Nami Public Documentation
Sign In
Nami Documentation
Nami Documentation
  • Get Started
    • Overview
      • Key Concepts
      • Data Collection
      • Built for Privacy
    • Evaluating Nami
    • SDKs
      • Apple Native SDK
      • Android Native SDK
      • Amazon Native SDK
      • Roku Native SDK
      • React Native Cross-Platform SDK
      • Flutter Cross-Platform SDK
      • Unity Cross-Platform SDK
      • Release Notes
        • Find Nami SDK Version
    • Quickstart Guide
  • Subscription Management
    • Overview
    • Products
      • Archive Products
      • Sync Products
    • Entitlements
    • Customer Screen
    • Accounts and Login/Logout
    • Advanced Use Cases
      • Upgrades and Downgrades
      • Supported Purchase Change States by Platform
      • Restoring Purchases
      • Working with Consumable IAPs
  • No Code Paywalls
    • Overview
    • Paywall Creator
      • Using the Creator
      • Paywall Layout
      • Components
        • Editing, Deleting, Reordering
        • Hiding Components
        • Video
        • Collapse
      • Editable Properties
        • Focused Styling
        • Safe Area
      • Conditions
        • Notched Devices
        • Product Entitlements
      • Adding Products
      • Repeating Product Group
      • Product Fields
      • Capabilities
        • Featured Styling
        • Selected Styling
        • Custom Brand Fonts
        • Carousel
        • Trial Eligibility
        • Deeplink Button
        • Introductory Offer Eligibility
        • Login Check
        • Product Groups
        • Conditional Product Groups
        • Offer Eligibility and Purchasing
        • Screenreader Text
        • Personalization Tokens
        • Custom Variables
        • Multipage
        • Custom Data Source
        • Advanced Video Features
        • Product Error States
      • ❓FAQs
        • Designing Paywalls in Figma
        • Guide to Building a Paywall from Scratch
      • 🎁Releases
        • Roadmap
    • Paywall Templates
      • Pacific
      • Pacific Premium
      • Trident
      • Starfish
      • Mantis
      • Venice
      • Venice Premium
      • Honest
      • Catalina
      • Oyster
      • Puffin
      • Marina
      • Beluga
      • Driftwood
      • Lagoon
      • Pisces
      • Aquarius
      • Conch
      • Lionfish
      • Moray
      • Tetra
      • Lighthouse
      • Puffin Tablet
    • Managing Paywalls
      • Archiving a Paywall
      • Duplicate a Paywall
    • Paywall Smart Text
    • Pricing Eligibility States
    • Pricing Eligibility by Platform
    • Nami Paywalls in Different Languages
    • Legacy Paywalls
  • Campaigns
    • Placements
      • Create a Placement
      • Deeplink Placements
      • Archiving a Placement
      • Managing Lots of Placements
      • Export Placements
    • Campaigns
      • Campaign Filters
        • Campaign Use Cases
      • Archiving a Campaign
      • Scheduling a Campaign
      • Campaign Conversion Events
      • Managing Lots of Campaigns
      • Campaign Troubleshooting
    • A/B and Multivariate Testing
      • Selecting an A/B test winner
      • A/B Test Allocation
  • Integrations
    • All Integrations
    • Billing Platforms
      • Apple Integration
        • App Store Setup
          • Privacy Details
        • Platform Integration
        • App Store Server Notifications
        • Store Credentials
          • App Store Connect Shared Secret
          • Apple App Store Connect API
          • Apple In App Purchase
        • Add a Product
        • Platform Sync
        • SDK Integration
        • Troubleshooting
        • Testing and Development
          • Apple Testing Environments
          • Setting up Device Sandbox Test Environment
          • Setting up StoreKit config in Xcode
      • Google Integration
        • Google Play Store Setup
        • Platform Integration
        • Service Account
        • Real-time Developer Notifications
        • Add a Product
        • Platform Sync
        • SDK Setup
        • Troubleshooting
          • Supporting Android minSdkVersion 25 or lower
          • Requested product is not available for purchase
          • Unsupported Version of Play Billing
      • Amazon Appstore Integration
        • Create Amazon Android App
        • Platform Integration
        • Shared Key
        • Real-time Event Notifications
        • Add a Product
        • SDK Integration
        • Testing
      • Roku Integration
        • Platform Integration
        • API Key
        • Transaction Notifications
        • Add a Product
        • SDK Integration
      • Web Integration
    • Analytics Tools
      • Adobe Analytics
      • Amplitude
      • Google Analytics
      • mParticle
      • 3rd-Party Analytics
    • Subscription Management
      • Nami Subscription Management
      • Bring your Own Payment Code
    • CDP Integrations
      • Adobe CDP Integration
      • Amplitude CDP Integration
      • Custom CDP Integration
      • Generic CDP Integration
    • Other Integrations
      • Wicket Labs
      • Webhooks
        • Introduction to the Nami ML Event System
        • Event Types
          • Purchase Status Updates
          • Events for Upgrades, Downgrades, and Crossgrades
        • Event Subscriptions
        • Understanding Transferred Events and Accounts
      • API Access
    • Events Feed
  • Analytics
    • Using Charts
    • Paywall Analytics
      • Impressions
      • Paywall Conversion Rate
      • Sessions
      • Active Devices
    • Subscription Analytics
      • Revenue
      • MRR
      • Purchases
      • Trial Starts
  • Nami Account
    • Manage your Apps
      • Find your Nami App Platform ID
      • Setting up Legal Text for your Apps
    • Organization
      • Configuring Organization Security Policies
      • Billing
    • Invite your Team
      • Roles
    • Manage your Account
      • Two-Factor Authentication (2FA)
Powered by GitBook
On this page
  • 1. Add the SDK to your project
  • 2. Configure the SDK
  • 3. Launch a campaign to show a paywall
  • 4. Grant access to paid app features
  • Next Steps
  1. Get Started
  2. SDKs

Flutter Cross-Platform SDK

Last updated 8 months ago

Adding Nami to your app has a few steps for a basic app.

  1. Add the SDK to your project

  2. Configure the SDK

  3. Launch a campaign to show a paywall

  4. React to a purchase to grant access to paid content or features

We'll run through each of these below.

1. Add the SDK to your project

The Nami SDK for Flutter is available on . The library is a bridge that links to our full native SDKs and allow access to various Nami capabilities. The Flutter bridge currently supports both Android and iOS.

The code for the Flutter bridge is also as is an .

If you need help setting up your Flutter development environment, you can find instructions here: .

To add Nami to your Flutter project, add our package to your project dependencies in your pubspec.yaml file.

dependencies:
  nami_flutter: ^3.1.1

To install the package, run the following on the command line.

flutter pub get

2. Configure the SDK

We recommend that you configure the Nami SDK as early in your app's launch as possible. This will ensure the SDK is ready to receive and process purchases.

In Flutter apps we recommend placing this code in your initState method for your class that holds the App State.

First, make sure you have imported the correct modules.

import 'package:nami_flutter/nami.dart';
import 'package:nami_flutter/nami_configuration.dart';
import 'package:nami_flutter/nami_log_level.dart';

Now to setup Nami, you'll need to call the configure method with App Platform IDs for both Apple and Google.

@override
void initState() {
 	super.initState()
  
  var namiConfiguration = NamiConfiguration(
    appPlatformIdApple: "YOUR_APPLE_APP_PLATFORM_ID",
    appPlatformIdGoogle: "YOUR_GOOGLE_APP_PLATFORM_ID",
    namiLogLevel: NamiLogLevel.warn);
  Nami.configure(namiConfiguration);
  
  // other initialization
}

Nami recommends setting the log level to warn for apps on the store. info may be helpful during development to better understand what is going on. debug level has a lot of information and is likely only helpful to the Nami support team.

3. Launch a campaign to show a paywall

Now that you have the SDK configured, let's show a paywall in your app. This step requires that you have a live Campaign configured in the Control Center with a Paywall.

You may also optionally check if the SDK is able to raise the paywall at the time you are trying to display it.

var launchCampaignResult =
   await NamiCampaignManager.launch(label: "your_campaign_label");
 if (launchCampaignResult.error) {
   print('Campaign Launch Error -> '
         '${launchCampaignResult.error}');
 }

4. Grant access to paid app features

Once a user has made a purchase, you'll need to make sure to give them access to the content and features in your app that require a purchase. This is managed on the Nami platform through our entitlement engine.

The first option is to check whether a specific entitlement is active. This is done with the following code.

if (NamiEntitlementManager.isEntitlementActive("premium_access")) {
  // allow access to paid app features 
}

Nami also triggers a callback any time there is a change to the state of an entitlement. In the callback, the full list of currently active entitlements is provided. You can use this to store the state of whether a user has access to premium features locally in your app.

We recommend creating callback listeners as early as possible in your app to ensure you always have the correct entitlement state. The best spot to do this is right after calling the configure method.

NamiEntitlementManager.registerActiveEntitlementsHandler()
        .listen((activeEntitlements) {
      if (activeEntitlements.isNotEmpty) {
        print("Active entitlements found!");
        activeEntitlements.forEach((element) {
          print(element.toString());
        });
      } else {
        print("No active entitlements");
      }
    });

That's all the basics to get up and running with Nami using Flutter. For more use cases, explore the rest of our docs.

Next Steps

🎉 Congrats on having the basics in place!

Now you are ready to go further based upon your use cases:

pub.dev
available on our GitHub
example project
https://flutter.dev/docs/get-started/install
Connect the SDK to your Registration Flow & User Accounts