diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9fe1536..0c36b01 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+## 1.2.4
+
+* Android sdk升级4.3.0.1
+* ios sdk升级4.3.0.2
+* 优化广告Widget在原生加载成功后动态调整大小,与原生view保持一致
+
## 1.2.3
* Android sdk升级4.2.5.2
diff --git a/README.md b/README.md
index 0e172cc..2bff070 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# 字节跳动穿山甲广告 Flutter版本
-
+
@@ -15,12 +15,12 @@
## 本地环境
```
-[✓] Flutter (Channel stable, 2.10.0, on macOS 12.1 21C52 darwin-x64, locale zh-Hans-CN)
-[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
+[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-x64, locale zh-Hans-CN)
+[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
-[✓] Android Studio (version 2020.3)
-[✓] VS Code (version 1.63.2)
+[✓] Android Studio (version 2021.1)
+[✓] VS Code (version 1.64.2)
[✓] Connected device (4 available)
[✓] HTTP Host Availability
```
@@ -28,14 +28,14 @@
## 集成步骤
#### 1、pubspec.yaml
```Dart
-flutter_unionad: ^1.2.3
+flutter_unionad: ^1.2.4
```
引入
```Dart
import 'package:flutter_unionad/flutter_unionad.dart';
```
#### 2、Android
-SDK([4.2.5.2](https://www.csjplatform.com/union/media/union/download/log?id=4))已配置插件中无需额外配置,只需要在android目录中AndroidManifest.xml配置
+SDK([4.3.0.1](https://www.csjplatform.com/union/media/union/download/log?id=4))已配置插件中无需额外配置,只需要在android目录中AndroidManifest.xml配置
```Java
io.flutter.embedded_views_preview
diff --git a/android/build.gradle b/android/build.gradle
index 5433b84..021bb44 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -59,7 +59,7 @@ dependencies {
implementation "androidx.appcompat:appcompat:1.3.1"
// implementation 'com.squareup.okhttp3:okhttp:3.12.1'
// implementation 'com.pangle.cn:ads-sdk:+'
- implementation 'com.pangle.cn:ads-sdk-pro:4.2.5.2'
+ implementation 'com.pangle.cn:ads-sdk-pro:4.3.0.1'
// implementation(name: 'open_ad_sdk_4.0.0.1', ext: 'aar')
// implementation(name: 'tools_release', ext: 'aar')
}
diff --git a/android/src/main/kotlin/com/gstory/flutter_unionad/bannerad/BannerExpressAdView.kt b/android/src/main/kotlin/com/gstory/flutter_unionad/bannerad/BannerExpressAdView.kt
index 1d0852a..f1ab980 100644
--- a/android/src/main/kotlin/com/gstory/flutter_unionad/bannerad/BannerExpressAdView.kt
+++ b/android/src/main/kotlin/com/gstory/flutter_unionad/bannerad/BannerExpressAdView.kt
@@ -53,7 +53,7 @@ internal class BannerExpressAdView(var context: Context, var activity: Activity,
expressViewWidth = width.toFloat()
expressViewHeight = hight.toFloat()
mExpressContainer = FrameLayout(activity)
- Log.e("banner广告数量===>",expressAdNum.toString())
+ Log.e(TAG,expressAdNum.toString())
val mTTAdManager = get()
mTTAdNative = mTTAdManager.createAdNative(context.applicationContext)
channel = MethodChannel(messenger,FlutterunionadViewConfig.bannerAdView+"_"+id)
@@ -80,14 +80,14 @@ internal class BannerExpressAdView(var context: Context, var activity: Activity,
}
override fun onNativeExpressAdLoad(ads: List) {
- if (ads == null || ads.size == 0) {
+ if (ads == null || ads.isEmpty()) {
return
}
- Log.e("banner拉去到广告数量",ads.size.toString())
- mTTAd = ads[(0..ads.size - 1).random()]
+ Log.e(TAG,ads.size.toString())
+ mTTAd = ads[(ads.indices).random()]
if(null != expressTime && expressTime > 30){
//轮播间隔
- mTTAd!!.setSlideIntervalTime(expressTime.toInt() * 1000)
+ mTTAd!!.setSlideIntervalTime(expressTime * 1000)
}
bindAdListener(mTTAd!!)
startTime = System.currentTimeMillis()
@@ -98,6 +98,8 @@ internal class BannerExpressAdView(var context: Context, var activity: Activity,
private fun bindAdListener(ad: TTNativeExpressAd) {
+ var viewWidth = 0.0f
+ var viewHeight = 0.0f
ad.setExpressInteractionListener(object : ExpressAdInteractionListener {
override fun onAdClicked(view: View, type: Int) {
Log.e(TAG, "广告点击")
@@ -106,6 +108,8 @@ internal class BannerExpressAdView(var context: Context, var activity: Activity,
override fun onAdShow(view: View, type: Int) {
Log.e(TAG, "广告显示")
+ var map: MutableMap = mutableMapOf("width" to viewWidth, "height" to viewHeight)
+ channel?.invokeMethod("onShow",map)
}
override fun onRenderFail(view: View, msg: String, code: Int) {
@@ -114,7 +118,7 @@ internal class BannerExpressAdView(var context: Context, var activity: Activity,
}
override fun onRenderSuccess(view: View, width: Float, height: Float) {
- Log.e("ExpressView", "render suc:" + (System.currentTimeMillis() - startTime))
+ Log.e(TAG, "render suc:" + (System.currentTimeMillis() - startTime))
Log.e(TAG, "\nexpressViewWidth=$expressViewWidth " +
"\nexpressViewWidthDP=${UIUtils.px2dip(activity, expressViewWidth)}" +
"\nexpressViewHeight $expressViewHeight" +
@@ -127,11 +131,10 @@ internal class BannerExpressAdView(var context: Context, var activity: Activity,
mExpressContainer!!.removeAllViews()
// val mExpressContainerParams: FrameLayout.LayoutParams = FrameLayout.LayoutParams(UIUtils.dip2px(activity, width).toInt(), UIUtils.dip2px(activity, height).toInt())
// mExpressContainer!!.layoutParams = mExpressContainerParams
+ viewWidth = width
+ viewHeight = height
mExpressContainer!!.addView(view)
- channel?.invokeMethod("onShow","")
}
-
-
})
//dislike设置
bindDislike(ad, false)
diff --git a/android/src/main/kotlin/com/gstory/flutter_unionad/drawfeedad/DrawFeedExpressAdView.kt b/android/src/main/kotlin/com/gstory/flutter_unionad/drawfeedad/DrawFeedExpressAdView.kt
index baddb2a..7bdc905 100644
--- a/android/src/main/kotlin/com/gstory/flutter_unionad/drawfeedad/DrawFeedExpressAdView.kt
+++ b/android/src/main/kotlin/com/gstory/flutter_unionad/drawfeedad/DrawFeedExpressAdView.kt
@@ -111,6 +111,8 @@ internal class DrawFeedExpressAdView(var context: Context, var activity: Activit
})
//是否允许点击暂停视频播放
ad!!.setCanInterruptVideoPlay(true)
+ var viewWidth = 0.0f
+ var viewHeight = 0.0f
ad!!.setExpressInteractionListener(object : ExpressAdInteractionListener{
override fun onAdClicked(view: View, type: Int) {
Log.e(TAG, "广告点击")
@@ -119,7 +121,8 @@ internal class DrawFeedExpressAdView(var context: Context, var activity: Activit
override fun onAdShow(view: View, type: Int) {
Log.e(TAG, "广告显示")
- channel?.invokeMethod("onShow","");
+ var map: MutableMap = mutableMapOf("width" to viewWidth, "height" to viewHeight)
+ channel?.invokeMethod("onShow",map);
}
override fun onRenderFail(view: View, msg: String, code: Int) {
@@ -139,8 +142,10 @@ internal class DrawFeedExpressAdView(var context: Context, var activity: Activit
"\nheightDP= ${UIUtils.dip2px(activity, height)}")
//返回view的宽高 单位 dp
mExpressContainer!!.removeAllViews()
-// val mExpressContainerParams: FrameLayout.LayoutParams = FrameLayout.LayoutParams(UIUtils.dip2px(activity, width).toInt(), UIUtils.dip2px(activity, height).toInt())
-// mExpressContainer!!.layoutParams = mExpressContainerParams
+// val mExpressContainerParams: FrameLayout.LayoutParams = FrameLayout.LayoutParams(UIUtils.dip2px(activity, width).toInt(), UIUtils.dip2px(activity, height).toInt())
+// mExpressContainer!!.layoutParams = mExpressContainerParams
+ viewWidth = width
+ viewHeight = height
mExpressContainer!!.addView(view)
}
})
diff --git a/android/src/main/kotlin/com/gstory/flutter_unionad/nativead/NativeExpressAdView.kt b/android/src/main/kotlin/com/gstory/flutter_unionad/nativead/NativeExpressAdView.kt
index 0f8ae29..5ff6dd0 100644
--- a/android/src/main/kotlin/com/gstory/flutter_unionad/nativead/NativeExpressAdView.kt
+++ b/android/src/main/kotlin/com/gstory/flutter_unionad/nativead/NativeExpressAdView.kt
@@ -79,12 +79,12 @@ class NativeExpressAdView(var context: Context,var activity: Activity, var messe
}
override fun onNativeExpressAdLoad(ads: List) {
- if (ads == null || ads.size == 0) {
+ if (ads == null || ads.isEmpty()) {
Log.e(TAG, "未拉取到信息流广告")
return
}
//随机获取一条广告显示
- mTTAd = ads[(0..ads.size - 1).random()]
+ mTTAd = ads[(ads.indices).random()]
bindAdListener(mTTAd!!)
mTTAd!!.render() //调用render开始渲染广告
}
@@ -116,7 +116,8 @@ class NativeExpressAdView(var context: Context,var activity: Activity, var messe
// mExpressContainerParams.gravity = Gravity.CENTER
// mExpressContainer!!.layoutParams = mExpressContainerParams
mExpressContainer!!.addView(view)
- channel?.invokeMethod("onShow","")
+ var map: MutableMap = mutableMapOf("width" to width, "height" to height)
+ channel?.invokeMethod("onShow",map)
}
})
//dislike设置
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index e5f6364..df2bb9e 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -261,6 +261,7 @@
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
C93139E4786FB670B9012E8C /* [CP] Copy Pods Resources */,
+ 4D762FC80C06878CECE39CFB /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -334,6 +335,23 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n";
};
+ 4D762FC80C06878CECE39CFB /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
diff --git a/ios/Classes/bannerad/BannerAdView.swift b/ios/Classes/bannerad/BannerAdView.swift
index 240d6a0..d98d219 100644
--- a/ios/Classes/bannerad/BannerAdView.swift
+++ b/ios/Classes/bannerad/BannerAdView.swift
@@ -39,7 +39,7 @@ public class BannerAdView : NSObject,FlutterPlatformView{
public func view() -> UIView {
return self.container
}
-
+
private func loadBannerExpressAd(){
self.removeAllView()
let viewWidth:CGFloat = CGFloat(self.expressViewWidth!)
@@ -86,7 +86,9 @@ extension BannerAdView: BUNativeExpressBannerViewDelegate {
public func nativeExpressBannerAdViewRenderSuccess(_ bannerAdView: BUNativeExpressBannerView) {
LogUtil.logInstance.printLog(message: "banner渲染成功")
- self.channel?.invokeMethod("onShow", arguments: "")
+ let map : NSDictionary = ["width":bannerAdView.frame.size.width,
+ "height":bannerAdView.frame.size.height]
+ self.channel?.invokeMethod("onShow", arguments: map)
}
public func nativeExpressBannerAdViewDidClick(_ bannerAdView: BUNativeExpressBannerView) {
diff --git a/ios/Classes/drawfeedad/DrawFeedAdView.swift b/ios/Classes/drawfeedad/DrawFeedAdView.swift
index e48bb50..eb92028 100644
--- a/ios/Classes/drawfeedad/DrawFeedAdView.swift
+++ b/ios/Classes/drawfeedad/DrawFeedAdView.swift
@@ -75,35 +75,36 @@ extension DrawFeedAdView : BUNativeExpressAdViewDelegate{
//view加载成功
public func nativeExpressAdSuccess(toLoad nativeExpressAd: BUNativeExpressAdManager, views: [BUNativeExpressAdView]) {
let view : BUNativeExpressAdView
- LogUtil.logInstance.printLog(message: "nativeExpressAdSuccess加载成功")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd加载成功")
if(views.count > 0){
view = views[0]
view.rootViewController = MyUtils.getVC()
view.render()
self.container.addSubview(view)
- self.channel?.invokeMethod("onShow", arguments: "")
+ let map : NSDictionary = ["width":view.frame.size.width,
+ "height":view.frame.size.height]
+ self.channel?.invokeMethod("onShow", arguments: map)
}
}
//加载失败
public func nativeExpressAdFail(toLoad nativeExpressAd: BUNativeExpressAdManager, error: Error?) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdFail")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd Fail")
LogUtil.logInstance.printLog(message: error)
self.channel?.invokeMethod("onFail", arguments: String(error.debugDescription))
}
public func nativeExpressAdViewRenderSuccess(_ nativeExpressAdView: BUNativeExpressAdView) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdViewRenderSuccess")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd RenderSuccess")
}
public func nativeExpressAdView(_ nativeExpressAdView: BUNativeExpressAdView, dislikeWithReason filterWords: [BUDislikeWords]) {
self.disposeView()
- LogUtil.logInstance.printLog(message: "nativeExpressAdView")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd onDislike")
self.channel?.invokeMethod("onDislike", arguments: filterWords[0].name)
}
public func nativeExpressAdView(_ nativeExpressAdView: BUNativeExpressAdView, stateDidChanged playerState: BUPlayerPlayState) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdView")
switch playerState {
case BUPlayerPlayState.statePlaying:
self.channel?.invokeMethod("onVideoPlay", arguments: "")
@@ -121,25 +122,25 @@ extension DrawFeedAdView : BUNativeExpressAdViewDelegate{
}
public func nativeExpressAdViewWillShow(_ nativeExpressAdView: BUNativeExpressAdView) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdViewWillShow")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd WillShow")
}
public func nativeExpressAdViewDidClick(_ nativeExpressAdView: BUNativeExpressAdView) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdViewDidClick")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd DidClick")
self.channel?.invokeMethod("onClick", arguments: nil)
}
public func nativeExpressAdViewWillPresentScreen(_ nativeExpressAdView: BUNativeExpressAdView) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdViewWillPresentScreen")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd WillPresentScreen")
}
public func nativeExpressAdViewRenderFail(_ nativeExpressAdView: BUNativeExpressAdView, error: Error?) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdViewRenderFail")
+ LogUtil.logInstance.printLog(message: "DrawfeedAdv RenderFail")
LogUtil.logInstance.printLog(message: error.debugDescription)
self.channel?.invokeMethod("onFail", arguments: String(error.debugDescription))
}
public func nativeExpressAdViewDidCloseOtherController(_ nativeExpressAdView: BUNativeExpressAdView, interactionType: BUInteractionType) {
- LogUtil.logInstance.printLog(message: "nativeExpressAdViewDidCloseOtherController")
+ LogUtil.logInstance.printLog(message: "DrawfeedAd DidCloseOtherController")
}
}
diff --git a/ios/Classes/nativead/NativeAdView.swift b/ios/Classes/nativead/NativeAdView.swift
index 88fae51..733a3ee 100644
--- a/ios/Classes/nativead/NativeAdView.swift
+++ b/ios/Classes/nativead/NativeAdView.swift
@@ -83,7 +83,9 @@ extension NativeAdView : BUNativeExpressAdViewDelegate{
view.rootViewController = MyUtils.getVC()
view.render()
self.container.addSubview(view)
- self.channel?.invokeMethod("onShow", arguments: "")
+ let map : NSDictionary = ["width":view.frame.size.width,
+ "height":view.frame.size.height]
+ self.channel?.invokeMethod("onShow", arguments: map)
}
}
diff --git a/ios/flutter_unionad.podspec b/ios/flutter_unionad.podspec
index 9708fde..a9c951f 100644
--- a/ios/flutter_unionad.podspec
+++ b/ios/flutter_unionad.podspec
@@ -18,7 +18,7 @@ A new flutter plugin project.
s.dependency 'Flutter'
s.platform = :ios, '9.0'
#s.dependency 'Ads-CN','~> 4.2.5.1'
- s.dependency 'Ads-CN-Beta','~> 4.2.5.2'
+ s.dependency 'Ads-CN-Beta','~> 4.3.0.2'
# .framework文件
# s.vendored_frameworks = 'PangleSDK/BUAdSDK.framework','PangleSDK/BUCNAuxiliary.framework','PangleSDK/BUFoundation.framework'
# .a文件
diff --git a/lib/bannerad/BannerAdView.dart b/lib/bannerad/BannerAdView.dart
index 45b89b8..d8b5ec3 100644
--- a/lib/bannerad/BannerAdView.dart
+++ b/lib/bannerad/BannerAdView.dart
@@ -41,10 +41,16 @@ class _BannerAdViewState extends State {
//广告是否显示
bool _isShowAd = true;
+ //宽高
+ double _width = 0;
+ double _height = 0;
+
@override
void initState() {
super.initState();
_isShowAd = true;
+ _width = widget.expressViewWidth;
+ _height = widget.expressViewHeight;
}
@override
@@ -54,8 +60,8 @@ class _BannerAdViewState extends State {
}
if (defaultTargetPlatform == TargetPlatform.android) {
return Container(
- width: widget.expressViewWidth,
- height: widget.expressViewHeight,
+ width: _width,
+ height: _height,
child: AndroidView(
viewType: _viewType,
creationParams: {
@@ -74,8 +80,8 @@ class _BannerAdViewState extends State {
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return Container(
- width: widget.expressViewWidth,
- height: widget.expressViewHeight,
+ width: _width,
+ height: _height,
child: UiKitView(
viewType: _viewType,
creationParams: {
@@ -108,6 +114,14 @@ class _BannerAdViewState extends State {
switch (call.method) {
//显示广告
case FlutterUnionadMethod.onShow:
+ Map map = call.arguments;
+ if (mounted) {
+ setState(() {
+ _isShowAd = true;
+ _width = (map["width"]).toDouble();
+ _height = (map["height"]).toDouble();
+ });
+ }
widget.callBack?.onShow!();
break;
//广告加载失败
diff --git a/lib/drawfeedad/DrawFeedAdView.dart b/lib/drawfeedad/DrawFeedAdView.dart
index bd3fe20..ed5f5eb 100644
--- a/lib/drawfeedad/DrawFeedAdView.dart
+++ b/lib/drawfeedad/DrawFeedAdView.dart
@@ -38,10 +38,16 @@ class _DrawFeedAdViewState extends State {
//广告是否显示
bool _isShowAd = true;
+ //宽高
+ double _width = 0;
+ double _height = 0;
+
@override
void initState() {
super.initState();
_isShowAd = true;
+ _width = widget.expressViewWidth;
+ _height = widget.expressViewHeight;
}
@override
@@ -51,8 +57,8 @@ class _DrawFeedAdViewState extends State {
}
if (defaultTargetPlatform == TargetPlatform.android) {
return Container(
- width: widget.expressViewWidth,
- height: widget.expressViewHeight,
+ width: _width,
+ height: _height,
child: AndroidView(
viewType: _viewType,
creationParams: {
@@ -69,8 +75,8 @@ class _DrawFeedAdViewState extends State {
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return Container(
- width: widget.expressViewWidth,
- height: widget.expressViewHeight,
+ width: _width,
+ height: _height,
child: UiKitView(
viewType: _viewType,
creationParams: {
@@ -98,10 +104,17 @@ class _DrawFeedAdViewState extends State {
//监听原生view传值
Future _platformCallHandler(MethodCall call) async {
- print("====> ${call.method} ${call.arguments}");
switch (call.method) {
//显示广告
case FlutterUnionadMethod.onShow:
+ Map map = call.arguments;
+ if (mounted) {
+ setState(() {
+ _isShowAd = true;
+ _width = (map["width"]).toDouble();
+ _height = (map["height"]).toDouble();
+ });
+ }
if (widget.callBack != null) {
widget.callBack?.onShow!();
}
diff --git a/lib/nativead/NativeAdView.dart b/lib/nativead/NativeAdView.dart
index 4273fb0..e0b4fec 100644
--- a/lib/nativead/NativeAdView.dart
+++ b/lib/nativead/NativeAdView.dart
@@ -38,10 +38,16 @@ class _NativeAdViewState extends State {
//广告是否显示
bool _isShowAd = true;
+ //宽高
+ double _width = 0;
+ double _height = 0;
+
@override
void initState() {
super.initState();
_isShowAd = true;
+ _width = widget.expressViewWidth;
+ _height = widget.expressViewHeight;
}
@override
@@ -51,8 +57,8 @@ class _NativeAdViewState extends State {
}
if (defaultTargetPlatform == TargetPlatform.android) {
return Container(
- width: widget.expressViewWidth,
- height: widget.expressViewHeight,
+ width: _width,
+ height: _height,
child: AndroidView(
viewType: _viewType,
creationParams: {
@@ -70,8 +76,8 @@ class _NativeAdViewState extends State {
);
} else if (defaultTargetPlatform == TargetPlatform.iOS) {
return Container(
- width: widget.expressViewWidth,
- height: widget.expressViewHeight,
+ width: _width,
+ height: _height,
child: UiKitView(
viewType: _viewType,
creationParams: {
@@ -103,9 +109,15 @@ class _NativeAdViewState extends State {
switch (call.method) {
//显示广告
case FlutterUnionadMethod.onShow:
- if (widget.callBack != null) {
- widget.callBack?.onShow!();
+ Map map = call.arguments;
+ if (mounted) {
+ setState(() {
+ _isShowAd = true;
+ _width = (map["width"]).toDouble();
+ _height = (map["height"]).toDouble();
+ });
}
+ widget.callBack?.onShow!();
break;
//广告加载失败
case FlutterUnionadMethod.onFail:
@@ -114,9 +126,7 @@ class _NativeAdViewState extends State {
_isShowAd = false;
});
}
- if (widget.callBack != null) {
- widget.callBack?.onFail!(call.arguments);
- }
+ widget.callBack?.onFail!(call.arguments);
break;
//广告不感兴趣
case FlutterUnionadMethod.onDislike:
@@ -125,15 +135,11 @@ class _NativeAdViewState extends State {
_isShowAd = false;
});
}
- if (widget.callBack != null) {
- widget.callBack?.onDislike!(call.arguments);
- }
+ widget.callBack?.onDislike!(call.arguments);
break;
//点击
case FlutterUnionadMethod.onClick:
- if (widget.callBack != null) {
- widget.callBack?.onClick!();
- }
+ widget.callBack?.onClick!();
break;
}
}
diff --git a/pubspec.yaml b/pubspec.yaml
index 055b023..dcd7de5 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: flutter_unionad
description: A flutter plugin for Bytedance-UnionAD.It is convenient for Android and IOS to directly call the method and native view of advertisement SDK.
-version: 1.2.3
+version: 1.2.4
homepage: https://github.com/gstory0404/flutter_unionad
environment: