Conscent.ai Developer Documentation
  • Version 2.0
    • Using Conscent.ai
    • Web SDK
    • Login
    • Logout
    • User Details Drawer
    • Google One Tap
    • Mobile SDK
      • iOS(Swift)
        • In-App Purchases with Conscent
      • Android SDK
      • React Native SDK
      • Google In-App Purchases with Conscent
      • Apple In-App Purchases with Conscent
    • Facebook SSO Integration Guide
    • Landing Page API v 2.0
    • AMP Integration
    • Integrating APIs(v2)
      • Purchase Details
      • User Registered Or Not
      • User Registrations
      • Subscription Plans Details
      • Get User Details
      • Add Subscription If User Registered
      • Update UserDetails
      • Update SubscriptionDetails
      • Get All Transaction Details
    • IAM System API Documentation
  • Version 1.0
    • Getting Started
    • On Board
    • Using Conscent.ai
    • Authentication
    • Web SDK
    • Login
    • Logout
    • Amp Documentation
    • Mobile SDK
      • Android
      • Flutter
      • iOS(Swift)
      • React Native SDK
    • Auto Login
    • Creating External Purchases
    • Landing Page API
  • Login Screen Customization
  • Integrating Client Payment Gateway
  • Integrating with APIs
    • User Details and Subscriptions Information
    • Purchased Subscriptions
    • User and Purchase Details
    • Client Purchases
    • Client Micropayments
    • Client Passes
    • Cancel Active Subscriptions
    • Delete User
  • Events API Docs
    • Different Types of Events
    • SSO Login Flow
  • Discount Coupon
    • Dynamic Coupon API Generation:
  • New Webhooks
    • Meter Banner Webhook
    • Paywall Webhook
    • SignUp Webhook
    • Refund Webhook
    • Purchase Webhook
    • Subscription Landing Page Webhook
    • Popup Webhook
    • User Update Webhook
    • Payment Gateway Webhook
    • Review Page Webhook
    • Transaction Webhook
    • Login Webhook
    • Cancel Subscription Webhook
  • Old Webhooks
    • Sign Up Webhook
    • Login Webhook
    • Subscription Payment Webhook
    • Subscription Cancelled Webhook
    • Pass Payment Webhook
    • Subscription Bundle Payment Webhook
    • Review Subscription Webhook
    • Micro Payment Webhook
    • How to validate Webhooks?
  • Registering The Content
    • Create Content
    • Edit Content
    • View Content
  • Country Code List
  • Supported Currencies and Payment Gateways
    • Stripe Supported Country with Currency
    • Razorpay Supported Country with Currency
    • Paypal Supported Country with Currency
  • Errors
  • Loyalty System
    • Web SDK
    • iOS SDK
    • Android SDK
    • Flutter SDK
    • API from server
Powered by GitBook
On this page
  1. Version 1.0
  2. Mobile SDK

Flutter

This is a step-by-step guide to including Conscent.ai Plugin in your app. This plugin is developed in Flutter and supports both Android and IOS Devices.

PreviousAndroidNextiOS(Swift)

Last updated 11 months ago

Installation

Use package as a library

Depend on it

Run this command with Flutter:

flutter pub add flutter_conscent_plugin

This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get):

dependencies:
  flutter_conscent_plugin: ^0.4.2

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

Import it

Now in your Dart code, you can use:

import 'package:flutter_conscent_plugin/flutter_conscent_plugin.dart';
Initialize SDK

In your application pass these fields in your app.

  • client_id - Pass your clientId received from Conscent.ai.

  • ENVIRONMENTMODE - configuration testing of different environments available.

ENVIRONMENTMODE can be set as :
    ENVIRONMENTMODE.SANDBOX 
    ENVIRONMENTMODE.PRODUCTION

The below code can be used as a sample:

ConscentInitializer("your_client_id", ENVIRONMENTMODE.SANDBOX);

Initialize Paywall

  1. Pass client content id in setContentId(clientContentId) Method:

Attaching the code below for the refernce:

ConscentInitializer.setContentId('your_content_id');
  1. Check content access and show the paywall:

bool showContent = false;

 FutureBuilder<bool>(
  future: ConscentMethods().getContentAccess(),
  builder: (context, snapshot){
  
  if (snapshot.hasData) {
       var responseData = snapshot.data;
         if (responseData != null) {
           showContent = responseData;
         }
       
       return Center(
                  child: Stack(
                    children: <Widget>[
                      SingleChildScrollView(
                        controller: scrollController,
                        child: Container(
                          width: MediaQuery.of(context).size.width,
                          height: MediaQuery.of(context).size.height,
                          padding: const EdgeInsets.all(20.0),
                          alignment: Alignment.topCenter,
                          child: YourContentPage(),
                        ),
                      ),
                      if (!showContent)
                        Container(
                            width: MediaQuery.of(context).size.width,
                            height: MediaQuery.of(context).size.height,
                            alignment: Alignment.bottomCenter,
                            child: Paywall((response) {
                              if (responseData != null) {
                                  showContent = responseData;
                              }
                              setState(() {});
                            })),
                    ],
                  ),
                );
               
  }else if (snapshot.hasError) {
    return ShowYourErrorPage();
  }
 },
), 

These methods need to be called on the Content Page.

Handling Events

  1. Scroll Listener Event

scrollController.addListener(() {
      onScollDepth = max(scrollController.offset, onScollDepth);
      height = scrollController.position.maxScrollExtent;

      ConscentMethods().setScollDepthHeight(onScollDepth, height);

      ConscentMethods().onTouchListener();
    });
  1. Exit from the Content page

@override
void dispose() {
  super.dispose();
  ConscentMethods().pageExitEvent();
}

The below method is called to Logout from Conscent.ai

ConscentMethods().userLogOut()
this