flutter_oewa 1.0.8 copy "flutter_oewa: ^1.0.8" to clipboard
flutter_oewa: ^1.0.8 copied to clipboard

A flutter package wrapper around the OEWA Android and iOS SDKs.

example/lib/main.dart

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

import 'package:flutter_oewa/flutter_oewa.dart';
import 'package:flutter_oewa_example/widgets/tracking_buttons.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();

    initOewa();
  }

  bool _optOut = false;

  // Initializes our OEWA tracking session
  Future<void> initOewa() async {
    // defines your unique vendor id (you get this from your OEWA account)
    const offerIdentifier = 'my_company_key';

    // defines whether debug messages should be logged for development
    const debugMode = true;

    // start the session
    await Oewa.initIOLSession(
      offerIdentifier,
      debugMode: debugMode,
      optOutState: false,
      privacyMode: true,
    );
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [
              const Center(
                child: Text(
                  'Check the logs to see whether requests go out or not!',
                ),
              ),

              // Demo buttons to log events
              const TrackingButtons(),

              // seperator
              const SizedBox(height: 100),

              // Opt out button
              if (_optOut == false)
                ElevatedButton(
                  onPressed: () async {
                    // opt out
                    await Oewa.optOut();

                    final newOptOutState = await Oewa.getOptOutStatus();

                    // set the state just to update ui
                    setState(() {
                      _optOut = newOptOutState;
                    });
                  },
                  child: const Text('Opt out'),
                ),

              // Opt in button
              if (_optOut == true)
                ElevatedButton(
                  onPressed: () async {
                    await Oewa.optIn('my_company_key');

                    final newOptOutState = await Oewa.getOptOutStatus();

                    // set the state just to update ui
                    setState(() {
                      _optOut = newOptOutState;
                    });
                  },
                  child: const Text('Opt in'),
                ),
            ],
          ),
        ),
      ),
    );
  }
}
4
likes
160
points
312
downloads

Publisher

verified publishermarqably.com

Weekly Downloads

A flutter package wrapper around the OEWA Android and iOS SDKs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface, shared_preferences

More

Packages that depend on flutter_oewa