startapp_sdk_flutter 0.0.7 copy "startapp_sdk_flutter: ^0.0.7" to clipboard
startapp_sdk_flutter: ^0.0.7 copied to clipboard

outdated

A startapp ads plugin

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:startapp_sdk_flutter/startapp_sdk_flutter.dart';
import 'package:startapp_sdk_flutter/src/startapp_banner.dart';
import 'package:startapp_sdk_flutter/src/startapp_banner_size.dart';

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

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

class _MyAppState extends State<MyApp> {
  GlobalKey<ScaffoldState> scaffoldState = GlobalKey();
  @override
  void initState() {
    super.initState();
    initApp();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initApp() async {
    Startapp.instance.initialize(appId: '202861171');
  }

  void showSnackBar(String content) {
    scaffoldState.currentState.showSnackBar(SnackBar(
      content: Text(content),
      duration: Duration(milliseconds: 10000),
    ));
  }

  void handleEvent(StartappEvent event) {
    switch (event) {
      case StartappEvent.onClick:
        showSnackBar('Received: onClick!');
        break;
      case StartappEvent.onReceiveAd:
        showSnackBar('Received: onReceiveAd');
        break;
      case StartappEvent.onImpression:
        showSnackBar('Received: onImpression');
        break;
      case StartappEvent.onFailedToReceiveAd:
        showSnackBar('Received: onFailedToReceiveAd');
        break;
        break;
      default:
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        key: scaffoldState,
        appBar: AppBar(
          title: const Text('Plugin example apps'),
        ),
        body: StartappBanner(
          listener: handleEvent,
          adSize: StartappBannerSize.BANNER,
        ),
      ),
    );
  }
}