karte_in_app_messaging 1.3.0 copy "karte_in_app_messaging: ^1.3.0" to clipboard
karte_in_app_messaging: ^1.3.0 copied to clipboard

Flutter plugin for KARTE In-app Messaging, provides a simple API to control in-app messaging. Supports on Android and iOS.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:karte_core/karte_core.dart';
import 'package:karte_in_app_messaging/karte_in_app_messaging.dart';

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  bool _isPresenting = false;

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    bool isPresenting;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      isPresenting = await InAppMessaging.isPresenting;
    } on PlatformException {
      isPresenting = false;
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _isPresenting = isPresenting;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('KARTE InAppMessaging example app'),
        ),
        body: Center(
          child: Column(
            // mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('isPresenting:  $_isPresenting'),
              ElevatedButton(
                onPressed: () => initPlatformState(),
                child: Text("checkPresent"),
              ),
              ElevatedButton(
                onPressed: () => InAppMessaging.dismiss(),
                child: Text("dismiss"),
              ),
              ElevatedButton(
                onPressed: () => InAppMessaging.suppress(),
                child: Text("suppress"),
              ),
              ElevatedButton(
                onPressed: () => InAppMessaging.unsuppress(),
                child: Text("unsuppress"),
              ),
              ElevatedButton(
                onPressed: () => Tracker.view("popup"),
                child: Text("view"),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
0
likes
160
pub points
82%
popularity

Publisher

unverified uploader

Flutter plugin for KARTE In-app Messaging, provides a simple API to control in-app messaging. Supports on Android and iOS.

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter, karte_core

More

Packages that depend on karte_in_app_messaging