1
0
mirror of https://github.com/flutter/samples.git synced 2026-05-10 17:07:28 +00:00

Flutter 3.29 beta (#2571)

This commit is contained in:
Eric Windmill
2025-02-12 18:08:01 -05:00
committed by GitHub
parent d62c784789
commit 719fd72c38
685 changed files with 76244 additions and 53721 deletions

View File

@@ -36,12 +36,15 @@ class AdsController {
void preloadAd() {
// TODO: When ready, change this to the Ad Unit IDs provided by AdMob.
// The current values are AdMob's sample IDs.
final adUnitId = defaultTargetPlatform == TargetPlatform.android
? 'ca-app-pub-3940256099942544/6300978111'
// iOS
: 'ca-app-pub-3940256099942544/2934735716';
_preloadedAd =
PreloadedBannerAd(size: AdSize.mediumRectangle, adUnitId: adUnitId);
final adUnitId =
defaultTargetPlatform == TargetPlatform.android
? 'ca-app-pub-3940256099942544/6300978111'
// iOS
: 'ca-app-pub-3940256099942544/2934735716';
_preloadedAd = PreloadedBannerAd(
size: AdSize.mediumRectangle,
adUnitId: adUnitId,
);
// Wait a bit so that calling at start of a new screen doesn't have
// adverse effects on performance.

View File

@@ -53,8 +53,11 @@ class _BannerAdWidgetState extends State<BannerAdWidget> {
if (_currentOrientation == orientation &&
_bannerAd != null &&
_adLoadingState == _LoadingState.loaded) {
_log.info(() => 'We have everything we need. Showing the ad '
'${_bannerAd.hashCode} now.');
_log.info(
() =>
'We have everything we need. Showing the ad '
'${_bannerAd.hashCode} now.',
);
return SizedBox(
width: _bannerAd!.size.width.toDouble(),
height: _bannerAd!.size.height.toDouble(),
@@ -123,7 +126,8 @@ class _BannerAdWidgetState extends State<BannerAdWidget> {
if (useAnchoredAdaptiveSize) {
final AnchoredAdaptiveBannerAdSize? adaptiveSize =
await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(
MediaQuery.of(context).size.width.truncate());
MediaQuery.of(context).size.width.truncate(),
);
if (adaptiveSize == null) {
_log.warning('Unable to get height of anchored banner.');
@@ -137,16 +141,19 @@ class _BannerAdWidgetState extends State<BannerAdWidget> {
if (!mounted) return;
assert(Platform.isAndroid || Platform.isIOS,
'AdMob currently does not support ${Platform.operatingSystem}');
assert(
Platform.isAndroid || Platform.isIOS,
'AdMob currently does not support ${Platform.operatingSystem}',
);
_bannerAd = BannerAd(
// This is a test ad unit ID from
// https://developers.google.com/admob/android/test-ads. When ready,
// you replace this with your own, production ad unit ID,
// created in https://apps.admob.com/.
adUnitId: Theme.of(context).platform == TargetPlatform.android
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716',
adUnitId:
Theme.of(context).platform == TargetPlatform.android
? 'ca-app-pub-3940256099942544/6300978111'
: 'ca-app-pub-3940256099942544/2934735716',
size: size,
request: const AdRequest(),
listener: BannerAdListener(

View File

@@ -31,8 +31,10 @@ class PreloadedBannerAd {
Future<BannerAd> get ready => _adCompleter.future;
Future<void> load() {
assert(Platform.isAndroid || Platform.isIOS,
'AdMob currently does not support ${Platform.operatingSystem}');
assert(
Platform.isAndroid || Platform.isIOS,
'AdMob currently does not support ${Platform.operatingSystem}',
);
_bannerAd = BannerAd(
// This is a test ad unit ID from