sanjagh_flutter 0.0.4 copy "sanjagh_flutter: ^0.0.4" to clipboard
sanjagh_flutter: ^0.0.4 copied to clipboard

Sanjagh plugin for Flutter Applications. Sanjagh is an Advertising Network That helps you monetize your app using Advanced methods. at this time we only support ads on Android Os.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:sanjagh_flutter/sanjagh_flutter.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    SanjaghFlutterPlugin.instance.initialize("bOwX7fTsz10X7TXQ1HcFvqldUgcvFfpP", market: SanjaghFlutterPlugin.MARKET_GOOGLE_PLAY, primaryColor: "#c44d47", userIdentifier: "Hossein");

    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion = "5";
    // Platform messages may fail, so we use a try/catch PlatformException.
//    try {
//      platformVersion = await SanjaghFlutterSdk.platformVersion;
//    } on PlatformException {
//      platformVersion = 'Failed to get platform version.';
//    }

    // 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(() {
      _platformVersion = platformVersion;
    });
  }

  InterstitialAd _interstitialAd;
  BannerAd _bannerAd;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: getListView(),
//        body: Center(
//          child: Column(
//            children: <Widget>[
//              SizedBox(
//                width: 400,
//                height: 200,
//                child: BannerAdView(
//                  adUnitId: "5mytHpN4fBGHsNoo",
//                  adListener: (AdEvent event) {
//                    print(event);
//                  },
//                ),
//              ),
//              SizedBox(
//                width: 400,
//                height: 200,
//                child: BannerAdView(
//                  adUnitId: "n6kPN0Ymsz8QeUR4",
//                  adListener: (AdEvent event) {
//                    print(event);
//                  },
//                ),
//              ),
//              RaisedButton(
//                child: Text('load'),
//                onPressed: () {
//                  bannerAd.load();
//                },
//              ),
//            ],
//          ),
//        ),
      ),
    );
  }
}

List<String> getListElements() {
  var items = List<String>.generate(100, (counter) => "Item $counter");
  return items;
}

Widget getListView() {
  var listItems = getListElements();

  var listView = ListView.builder(itemBuilder: (context, index) {
    if (index % 10 == 9) {
      return SizedBox(
        width: 100,
        height: 60,
        child: BannerAdView(
          adUnitId: "dMw6clFB4YCv9B0C",
          adListener: (AdEvent event, int errorCode){
            print("$event:$errorCode");
          },
        ),
      );
    }
    return ListTile(
      leading: Icon(Icons.arrow_right),
      title: Text(listItems[index]),
      onTap: () {
        debugPrint('${listItems[index]} was tapped');
      },
    );
  });

  return listView;
}
1
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Sanjagh plugin for Flutter Applications. Sanjagh is an Advertising Network That helps you monetize your app using Advanced methods. at this time we only support ads on Android Os.

Homepage

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on sanjagh_flutter