pangle_flutter 2.0.1 pangle_flutter: ^2.0.1 copied to clipboard
A Flutter plugin that supports ByteDance Pangle SDK on Android and iOS. Such as Splash Ads, Rewarded Video Ads, etc.
/*
* Copyright (c) 2021 nullptrX
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:pangle_flutter/pangle_flutter.dart';
import 'package:pangle_flutter_example/common/version.dart';
import 'common/common.dart';
import 'page/constant.dart';
import 'page/express/custom_splash_page.dart';
/// 使用本插件需要知道的几个类,基本覆盖了开始使用时需要用到的入口类
///
/// [pangle] 加载广告的核心工具类
/// [PangleHelper] 辅助加载广告使用的帮助类
/// [PangleExpressSize] 模板类广告请求宽高设置
///
/// [PangleResult] 普通加载广告返回的结果
///
/// [SplashView] 开屏广告Widget
///
/// [PangleAd] 信息流加载获得的数据源
/// [FeedView] 信息流广告Widget
///
/// [NativeBannerView] 横幅广告Widget
///
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await initPangle();
await initVersion();
runApp(const PangleApp());
}
/// 范例入口
class PangleApp extends StatelessWidget {
const PangleApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
///
home: const CustomSplashPage(isRoot: true),
theme: kThemeData,
);
}
}
/// 初始化广告sdk
///
/// 工具类根据平台不同会有不同的配置
/// [iOS] iOS平台配置参数
/// [android] android平台配置参数
Future<void> initPangle() async {
PangleResult ret = await pangle.init(
iOS: const IOSConfig(
appId: kAppId,
logLevel: PangleLogLevel.debug,
),
android: const AndroidConfig(
appId: kAppId,
debug: false,
allowShowNotify: true,
useTextureView: true,
directDownloadNetworkType: [
AndroidDirectDownloadNetworkType.k2G,
]),
);
debugPrint(ret.toString());
}