Last updated:
0 purchases
appflow flutter
Flutter set up instructions #
Instructions For Installing Appflow SDK For Flutter
Notices
Our plugin relies on Appflow SDK, so before you use the plugin, please go to Appflow official website to install and configure Appflow SDK for Android and IOS.
Requirements
Minimum target: Android 21+
Installation
To use this plugin, add appflow_flutter as a dependency in your pubspec.yaml file (and run an implicit dart pub get):
dependencies:
appflow_flutter: ^0.0.4
copied to clipboard
Alternatively run this command:
flutter pub add appflow_flutter
copied to clipboard
Import Appflow
You should now be able to import appflow_flutter
import 'package:appflow_flutter/appflow_flutter.dart';
copied to clipboard
**Initialize **
Add the following to your App
@override
void initState() {
super.initState();
AppFlowFlutter().setup();
}
copied to clipboard
Set user id (optional)
You can set the user id in the following way
@override
void initState() {
super.initState();
AppFlowFlutter().setup(appUserId: "your_user_id");
}
copied to clipboard
Enable SDK log (optional)
You can enable SDK log output before initializing the SDK
@override
void initState() {
super.initState();
AppFlowFlutter().setup(appUserId: "your_user_id",logEnable: true);
}
copied to clipboard
Events
If you want to receive more events than usual:
You can send statistics events to Appflow backend in the following ways
AppFlowFlutter().sendEvent({String? eventName, Map<String, String>? attributes});
copied to clipboard
Example
sendEvent() async {
try {
var map = <String,String>{};
map["test"] = "123";
map["test2"] = "abc";
await _appflowFlutterPlugin.sendEvent(eventName: "test",attributes: map);
} catch (e) {
}
}
copied to clipboard
Purchases
This part of SDK is important for subscriptions information
Ready to work
a、Configure product information in Google Play
b、Add product information in dash.appflow.ai
Displaying Products
To fetch the products, you have to call method:
AppFlowFlutter().getSkuDetails({List<String>? skus});
copied to clipboard
Example
getSkuInfo() async {
try{
var list = ["yearly_v1"];
var data = (await _appflowFlutterPlugin.getSkuDetails(skus: list));
packageJson = data!["yearly_v1"];
}catch(e){
}
}
copied to clipboard
Making Purchases
Making Purchases, you have to call method:
AppFlowFlutter().purchasePackage(String skuDetail);
copied to clipboard
Example
purchasePackage() async {
if (packageJson.isEmpty) {
showConfirmDialog1("error", "please invoke getProductDetail method before invoke purchasePackage");
return;
}
try {
var data = await _appflowFlutterPlugin.purchasePackage(packageJson);
print(data);
} catch (e, stack) {
showConfirmDialog1("error", e.toString());
}
}
copied to clipboard
Subscription Status
Get the subscription status of a product, you have to call method:
AppFlowFlutter().getSubscriberInfo();
copied to clipboard
Example
getSubscriberInfo() async {
try{
var data = await _appflowFlutterPlugin.getSubscriberInfo();
}catch(e){
showConfirmDialog1("error", e.toString());
}
}
copied to clipboard
Upgrade/Downgrade product
To upgrade/downgrade a product, you have to call method:
AppFlowFlutter().upgradeInfo(
String oldSku, String skuDetail, int? prorationMode);
copied to clipboard
Example
upgradeProduct() async {
try {
var old = "yearly_v1";
var skuDetailJson = "";
var data = await _appflowFlutterPlugin.upgradeInfo(
old, skuDetailJson, ProrationMode.DEFERRED);
} on PlatformException {}
}
copied to clipboard
User info
You can send user information to Appflow backend in the following ways
AppFlowFlutter().uploadUserInfo(
{String? userName,
String? phone,
int? age,
String? email,
GenderType? gender,
Map<String, dynamic>? attribute});
copied to clipboard
Example
upgradeUserInfo() async {
try {
var map = <String, String>{};
map["test"] = "123";
map["test2"] = "abc";
var data = await _appflowFlutterPlugin.uploadUserInfo(
userName: "appflow",
phone: "1233",
age: 11,
email: "[email protected]",
gender: GenderType.female,
attribute: map);
} on PlatformException {}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.