yodosdk 1.0.6 copy "yodosdk: ^1.0.6" to clipboard
yodosdk: ^1.0.6 copied to clipboard

Yodo1 Ads Sdk.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:yodosdk/Banner/BannerAdCallback.dart';
import 'package:yodosdk/Banner/Yodo_BannerAd.dart';
import 'package:yodosdk/Init/InitAdCallback.dart';
import 'package:yodosdk/Inter/FullScreenAdCallbacks.dart';
import 'package:yodosdk/Native/NativeAdCallback.dart';
import 'package:yodosdk/Native/YodoNativeAd.dart';
import 'package:yodosdk/Reward/RewardAdCallbacks.dart';
import 'package:yodosdk/yodosdk.dart';
import 'package:yodosdk_example/banner_view.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  String interStatus = "No Status";
  String rewardStatus = "No Status";
  String initStatus = "Not Init";
  String rewardInterStatus = "No Status";
  String nativeStatus = "No Status";
  String bannerStatus = "No Status";
  bool adLoader = false;

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlugin() async {
    // await Yodosdk.showPrivacyDialog();
    await Yodosdk.initSdk(
      appId: "FPbdes7ukg",
      preLoadAds: true,
      showPrivacyDialog: true,
      initAdCallback: InitAdCallback(
        onSuccess: () {
          setInitStatus("Success");
          print("Success Init ============>");
        },
        onError: (error) {
          setInitStatus(error.toString());
          print("Error Init ======> $error");
        },
      ),
    );
  }

  setInitStatus(String status) {
    if (mounted) {
      setState(() {
        initStatus = status;
      });
    }
  }

  setNativeStatus(String status) {
    if (mounted) {
      setState(() {
        nativeStatus = status;
      });
    }
  }

  setBannerStatus(String status) {
    if (mounted) {
      setState(() {
        bannerStatus = status;
      });
    }
  }

  onLoader() {
    if (mounted) {
      setState(() {
        adLoader = true;
      });
    }
  }

  offLoader() {
    if (mounted) {
      setState(() {
        adLoader = false;
      });
    }
  }

  setInterStatus(String status) {
    if (mounted) {
      setState(() {
        interStatus = status;
      });
    }
  }

  setRewardStatus(String status) {
    if (mounted) {
      setState(() {
        rewardStatus = status;
      });
    }
  }

  setRewardInterStatus(String status) {
    if (mounted) {
      setState(() {
        rewardInterStatus = status;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: const Color(0xFFE5873C),
          elevation: 0,
          title: const Text('Yodo1 Plugin Demo'),
        ),
        body: ListView(
          children: [
            const SizedBox(
              height: 10,
            ),
            Container(
              margin: const EdgeInsets.symmetric(horizontal: 10),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      const Text(
                        "Sdk Init Status:  ",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Expanded(
                          child: Text(
                        initStatus,
                        style: const TextStyle(fontWeight: FontWeight.w500),
                      )),
                    ],
                  ),
                  const Divider(),
                  Row(
                    children: [
                      const Text(
                        "Inter Status:  ",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Expanded(
                          child: Text(
                        interStatus,
                        style: const TextStyle(fontWeight: FontWeight.w500),
                      )),
                    ],
                  ),
                  const Divider(),
                  Row(
                    children: [
                      const Text(
                        "Reward Status:  ",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Expanded(
                          child: Text(
                        rewardStatus,
                        style: const TextStyle(fontWeight: FontWeight.w500),
                      )),
                    ],
                  ),
                  const Divider(),
                  Row(
                    children: [
                      const Text(
                        "Reward Inter Status:  ",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Expanded(
                          child: Text(
                        rewardInterStatus,
                        style: const TextStyle(fontWeight: FontWeight.w500),
                      )),
                    ],
                  ),
                  const Divider(),
                  Row(
                    children: [
                      const Text(
                        "Native Status:  ",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Expanded(
                          child: Text(
                        nativeStatus,
                        style: const TextStyle(fontWeight: FontWeight.w500),
                      )),
                    ],
                  ),
                  const Divider(),
                  Row(
                    children: [
                      const Text(
                        "Banner Status:  ",
                        style: TextStyle(fontWeight: FontWeight.bold),
                      ),
                      Expanded(
                        child: Text(
                          bannerStatus,
                          style: const TextStyle(fontWeight: FontWeight.w500),
                        ),
                      ),
                    ],
                  ),
                ],
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            adLoader
                ? const Center(child: CircularProgressIndicator())
                : Column(
                    children: [
                      Row(
                        children: [
                          Expanded(
                            child: Container(
                              margin:
                                  const EdgeInsets.symmetric(horizontal: 10),
                              child: MaterialButton(
                                color: const Color(0xFFE5873C),
                                elevation: 0,
                                onPressed: () {
                                  initPlugin();
                                },
                                child: const Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Icon(Icons.start, color: Colors.white),
                                    SizedBox(
                                      width: 10,
                                    ),
                                    Expanded(
                                      child: Text(
                                        "Init Plugin",
                                        style: TextStyle(color: Colors.white),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin:
                                  const EdgeInsets.symmetric(horizontal: 10),
                              child: MaterialButton(
                                color: const Color(0xFFE5873C),
                                elevation: 0,
                                onPressed: () {
                                  onLoader();
                                  Yodosdk.loadAndShowInter(
                                    fullScreenAdCallbacks:
                                        FullScreenAdCallbacks(
                                      onLoad: (adId) {
                                        offLoader();
                                        setInterStatus("Loaded");
                                      },
                                      onAdLoadFail: (adId) {
                                        offLoader();
                                        setInterStatus("Fail to Load ");
                                      },
                                      onAdOpen: (adId) {
                                        setInterStatus("Ad Open");
                                      },
                                      onAdOpenFail: (adId) {
                                        offLoader();
                                        setInterStatus("Failed to Open");
                                      },
                                      onClose: (adId) {
                                        offLoader();
                                        setInterStatus("Closed");
                                      },
                                    ),
                                  );
                                },
                                child: const Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Icon(Icons.fullscreen, color: Colors.white),
                                    SizedBox(
                                      width: 10,
                                    ),
                                    Text(
                                      "Inter Demo",
                                      style: TextStyle(color: Colors.white),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                      Row(
                        children: [
                          Expanded(
                            child: Container(
                              margin:
                                  const EdgeInsets.symmetric(horizontal: 10),
                              child: MaterialButton(
                                color: const Color(0xFFE5873C),
                                elevation: 0,
                                onPressed: () {
                                  onLoader();
                                  Yodosdk.loadAndShowReward(
                                    rewardAdCallbacks: RewardAdCallbacks(
                                      onRewardEarned: (adId) {
                                        offLoader();
                                        setRewardStatus("Earned");
                                      },
                                      onLoad: (adId) {
                                        offLoader();
                                        setRewardStatus("Loaded");
                                      },
                                      onAdLoadFail: (error) {
                                        offLoader();
                                        setRewardStatus("Fail to Load $error");
                                      },
                                      onAdOpen: (adId) {
                                        offLoader();
                                        setRewardStatus("Ad Open");
                                      },
                                      onAdOpenFail: (error) {
                                        offLoader();
                                        setRewardStatus("Failed to Open");
                                      },
                                      onClose: (adId) {
                                        offLoader();
                                        setRewardStatus("Closed");
                                      },
                                    ),
                                  );
                                },
                                child: const Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Icon(Icons.payments, color: Colors.white),
                                    SizedBox(
                                      width: 10,
                                    ),
                                    Expanded(
                                      child: Text(
                                        "Reward Demo",
                                        style: TextStyle(color: Colors.white),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                          Expanded(
                            child: Container(
                              margin:
                                  const EdgeInsets.symmetric(horizontal: 10),
                              child: MaterialButton(
                                color: const Color(0xFFE5873C),
                                elevation: 0,
                                onPressed: () {
                                  onLoader();
                                  Yodosdk.loadAndShowRewardInter(
                                    rewardAdCallbacks: RewardAdCallbacks(
                                      onRewardEarned: (adId) {
                                        offLoader();
                                        setRewardInterStatus("Earned");
                                      },
                                      onLoad: (adId) {
                                        offLoader();
                                        setRewardInterStatus("Loaded");
                                      },
                                      onAdLoadFail: (error) {
                                        offLoader();
                                        setRewardInterStatus(
                                            "Fail to Load $error");
                                      },
                                      onAdOpen: (adId) {
                                        offLoader();
                                        setRewardInterStatus("Ad Open");
                                      },
                                      onAdOpenFail: (error) {
                                        offLoader();
                                        setRewardInterStatus("Failed to Open");
                                      },
                                      onClose: (adId) {
                                        offLoader();
                                        setRewardInterStatus("Closed");
                                      },
                                    ),
                                  );
                                },
                                child: const Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  mainAxisAlignment: MainAxisAlignment.center,
                                  children: [
                                    Icon(Icons.paypal, color: Colors.white),
                                    SizedBox(
                                      width: 10,
                                    ),
                                    Expanded(
                                      child: Text(
                                        "Reward Inter Demo",
                                        style: TextStyle(color: Colors.white),
                                      ),
                                    )
                                  ],
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ],
                  ),
            const SizedBox(
              height: 10,
            ),
            Container(
              margin: const EdgeInsets.only(left: 10),
              child: const Text(
                "Native Demo",
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            Yodosdk.getNative(
              size: NativeSize.nativeLarge,
              nativeAdCallback: NativeAdCallback(
                onLoad: () {
                  setNativeStatus("OnLoaded");
                },
                onClosed: () {
                  setNativeStatus("onClose");
                },
                onLoadFailed: (errorMessage) {
                  setNativeStatus("On Error $errorMessage");
                },
              ),
            ),
            Yodosdk.getNative(
              size: NativeSize.nativeLarge,
              nativeAdCallback: NativeAdCallback(
                onLoad: () {
                  setNativeStatus("OnLoaded");
                },
                onClosed: () {
                  setNativeStatus("onClose");
                },
                onLoadFailed: (errorMessage) {
                  setNativeStatus("On Error $errorMessage");
                },
              ),
            ),
            Yodosdk.getNative(
              size: NativeSize.nativeLarge,
              nativeAdCallback: NativeAdCallback(
                onLoad: () {
                  setNativeStatus("OnLoaded");
                },
                onClosed: () {
                  setNativeStatus("onClose");
                },
                onLoadFailed: (errorMessage) {
                  setNativeStatus("On Error $errorMessage");
                },
              ),
            ),
            const SizedBox(
              height: 10,
            ),
            Container(
              margin: const EdgeInsets.only(left: 10),
              child: const Text(
                "Banner Demo",
                style: TextStyle(
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            Yodosdk.getBanner(
              size: BannerSize.adaptiveBanner,
              bannerAdCallback: BannerAdCallback(
                onLoad: () {
                  setBannerStatus("OnLoaded");
                },
                onClosed: () {
                  setBannerStatus("onClose");
                },
                onLoadFailed: (errorMessage) {
                  setBannerStatus("On Error $errorMessage");
                },
                onOpen: () {
                  setBannerStatus("On Banner Open");
                },
                onOpenFail: (String error) {
                  setBannerStatus("On Error $error");
                },
              ),
            ),
            Yodosdk.getBanner(
              size: BannerSize.adaptiveBanner,
              bannerAdCallback: BannerAdCallback(
                onLoad: () {
                  setBannerStatus("OnLoaded");
                },
                onClosed: () {
                  setBannerStatus("onClose");
                },
                onLoadFailed: (errorMessage) {
                  setBannerStatus("On Error $errorMessage");
                },
                onOpen: () {
                  setBannerStatus("On Banner Open");
                },
                onOpenFail: (String error) {
                  setBannerStatus("On Error $error");
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
0
points
126
downloads

Publisher

unverified uploader

Weekly Downloads

Yodo1 Ads Sdk.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on yodosdk