qonversion_flutter 0.2.5 copy "qonversion_flutter: ^0.2.5" to clipboard
qonversion_flutter: ^0.2.5 copied to clipboard

outdated

Powerful yet simple subscription analytics

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:qonversion_flutter/qonversion.dart';

void main() => runApp(MyApp());

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

class _MyAppState extends State<MyApp> {
  String _uid = 'Not Initialized Qonversion Yet';

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

  Future<void> initPlatformState() async {
    String uid;
    try {
      await Qonversion.launchWith(
        iosApiKey: '',
        androidApiKey: '',
        onComplete: (receivedUid) {
          uid = receivedUid;
          print(uid);
        },
      );
    } catch (e) {
      print('Failed to obtain uid from Qonversion.');
      print(e);
    }
    if (!mounted) return;

    setState(() => _uid = uid);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Qonversion example app'),
        ),
        body: Center(
          child: Text(
            'Qonversion uid: \n$_uid\n',
            textAlign: TextAlign.center,
          ),
        ),
      ),
    );
  }
}