旋转框未旋转横幅广告

时间:2019-10-05 13:41:24

标签: flutter dart

我使用旋转框旋转屏幕,但是横幅广告没有旋转,它们显示的是风景,而我想以90度旋转以纵向显示。那可能是因为我是在构建而不是在脚手架中显示广告,但是我无法在脚手架中显示横幅广告,任何人都可以解决吗?

class showdata extends StatefulWidget {
  @override
  _showdataState createState() => _showdataState();
}

class _showdataState extends State<showdata> {
  static final MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
    keywords: ['Games', 'Puzzles'],
  );
  BannerAd bannerAd;
  InterstitialAd interstitialAd;
  RewardedVideoAd rewardedVideoAd;

  BannerAd buildBanner() {
    return BannerAd(
      adUnitId: BannerAd.testAdUnitId,
      size: AdSize.banner,
      listener: (MobileAdEvent event) {
        print(event);
      },
    );
  }

  InterstitialAd buildInterstitial() {
    return InterstitialAd(
      adUnitId: InterstitialAd.testAdUnitId,
      targetingInfo: targetingInfo,
      listener: (MobileAdEvent event) {
        if (event == MobileAdEvent.failedToLoad) {
          interstitialAd..load();
        } else if (event == MobileAdEvent.closed) {
          interstitialAd = buildInterstitial()..load();
        }
        print(event);
      },
    );
  }

  @override
  void initState() {
    super.initState();
    FirebaseAdMob.instance.initialize(appId: FirebaseAdMob.testAppId);
    bannerAd = buildBanner()..load();
    interstitialAd = buildInterstitial()..load();
  }

  int counter = 0;
  @override
  Widget build(BuildContext context) {


    Future<bool> _onBackPressed() {
      if (counter < 1) {
        interstitialAd

          ..show();
        counter++;
      } else {
        bannerAd.dispose();
      Navigator.pop(context, true);
      Navigator.pop(context, true);
      }
    }
    count=1;
    return WillPopScope(
      child: Scaffold(
//        backgroundColor: Colors.yellow,
          body: RotatedBox(quarterTurns: 3,
              child: Stack(
                children: <Widget>[
                  Container(
                    child: RaisedButton(onPressed: null),
                  ),
                ],
              )),
          ),

      onWillPop: _onBackPressed,
    );
  }
}

0 个答案:

没有答案