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

outdated

A new Flutter plugin.

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
    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.initFlyySDK(
        "<partner-token>", FlyyFlutterPlugin.PRODUCTION);

    //set user name
    FlyyFlutterPlugin.setFlyyUser("1234567890");
  }

  Future<void> callSetUser() async {
    //set user name
    await FlyyFlutterPlugin.setFlyyUserName("Pooja");

    //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();
  }

  @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'),
            ),
          ),
        ),
      ),
    );
  }
}