flyy_flutter_plugin 1.0.13 copy "flyy_flutter_plugin: ^1.0.13" to clipboard
flyy_flutter_plugin: ^1.0.13 copied to clipboard

outdated

Flutter wrapper around our Android and iOS mobile SDKs

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flyy_flutter_plugin/flyy_flutter_plugin.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  var initResult = "";

  @override
  void initState() {
    super.initState();
    //To set your package name same as entered in Flyy Dashboard
    //this method is only for ios
    FlyyFlutterPlugin.setPackageName("com.theflyy.flyy_flutter_plugin_example");
    initFlyySdk();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  initFlyySdk() {
    //init sdk with your partner token and environment (staging/production)
    FlyyFlutterPlugin.initFlyySDKWithThemeColors(
        "<partner-token>", FlyyFlutterPlugin.PRODUCTION, "#701250", "#701250");
  }

  Future<void> callSetUser() async {
    FlyyFlutterPlugin.setFlyyReferralCode("23ftho9");
    FlyyFlutterPlugin.setFlyyUser("9876543210");

    //set user name
    await FlyyFlutterPlugin.setFlyyUserName("User Name");

    //send event with key and value as strings
    await FlyyFlutterPlugin.sendEvent("flutter_plugin_android", "test");

    //send event key as string and value as json data in map
    Map<String, String> jsonData = new Map();
    jsonData['json_test'] = 'success';
    jsonData['flutter_plugin'] = "tested";
    String result =
        await FlyyFlutterPlugin.sendJSONEvent("flutter_plugin", jsonData);
    if (result == "success") {
      //do your work here
    }

    callOfferPage();
  }

  Future<void> callOfferPage() async {
    FlyyFlutterPlugin.openFlyyOffersPage();
    // FlyyFlutterPlugin.openFlyyRewardsPage();
    // FlyyFlutterPlugin.openFlyyWalletPage();
    // FlyyFlutterPlugin.openFlyyGiftCardsPage();
    // FlyyFlutterPlugin.openFlyyReferralsPage();
    // FlyyFlutterPlugin.openFlyyQuizPage();
    // FlyyFlutterPlugin.openFlyyQuizListPage();
    // FlyyFlutterPlugin.openFlyyQuizHistoryPage();
    // FlyyFlutterPlugin.openFlyyStampsPage();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: GestureDetector(
          onTap: () {
            callSetUser();
          },
          child: Padding(
            padding: const EdgeInsets.all(20.0),
            child: Center(
              child: Text('Start Flyy'),
            ),
          ),
        ),
      ),
    );
  }
}
5
likes
0
points
967
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter wrapper around our Android and iOS mobile SDKs

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on flyy_flutter_plugin

Packages that implement flyy_flutter_plugin