showOffers method

  1. @override
Future<bool> showOffers(
  1. int presentationStyle,
  2. bool isTransparent,
  3. int topMargin,
  4. int rightMargin,
  5. int bottomMargin,
  6. int leftMargin,
  7. dynamic callback(
    1. bool
    ),
)
override

ShowOffers with specified configurations. presentationStyle must be either '0' or '1'. 0 - pop up style, 1 - full screen size. isTransparent must be either 'true' or 'false' indicates if offer background should be transparent or not. topMagin must be of int type and value from 0 to 15. it indicates top margin offset in percentage. rightMagin must be of int type and value from 0 to 15. it indicates right margin offset in percentage. bottomMargin must be of int type and value from 0 to 15. it indicates bottom margin offset in percentage. leftMargin must be of int type and value from 0 to 15. it indicates left margin offset in percentage. Returns a bool indicating that if showOffers call is successful or not. In case of error it can also throw exceptions.

Implementation

@override
Future<bool> showOffers(
    int presentationStyle,
    bool isTransparent,
    int topMargin,
    int rightMargin,
    int bottomMargin,
    int leftMargin,
    Function(bool) callback) async {
  try {
    final statusMessage = await methodChannel.invokeMethod("showOffers", {
      "presentationStyle": presentationStyle,
      "isTransparent": isTransparent,
      "topMargin": topMargin,
      "rightMargin": rightMargin,
      "bottomMargin": bottomMargin,
      "leftMargin": leftMargin
    });

    methodChannel.setMethodCallHandler((call) async {
      if (call.method == 'onDismiss') {
        // Handle method call
        callback(true);
      }
    });

    return statusMessage;
  } on PlatformException catch (error) {
    log(error.message as String);
    rethrow;
  }
}