Skip to content

Commit 3842d72

Browse files
committed
refactor(ads): remove local ad provider and related dependencies
- Remove LocalAdProvider and related imports - Remove local ad provider from adProviders map - Remove DataClient and DataRepository for local ads - Remove local ad fixtures and related data - Update logging messages to reflect removal of local ad provider
1 parent 2431192 commit 3842d72

File tree

1 file changed

+1
-39
lines changed

1 file changed

+1
-39
lines changed

lib/bootstrap.dart

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import 'package:flutter_news_app_mobile_client_full_source_code/ads/admob_ad_pro
1919
if (dart.library.io) 'package:flutter_news_app_mobile_client_full_source_code/ads/admob_ad_provider.dart';
2020
import 'package:flutter_news_app_mobile_client_full_source_code/ads/demo_ad_provider.dart';
2121
import 'package:flutter_news_app_mobile_client_full_source_code/ads/inline_ad_cache_service.dart';
22-
import 'package:flutter_news_app_mobile_client_full_source_code/ads/local_ad_provider.dart';
2322
import 'package:flutter_news_app_mobile_client_full_source_code/app/config/config.dart'
2423
as app_config;
2524
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/app_initializer.dart';
@@ -160,28 +159,14 @@ Future<Widget> bootstrap(
160159
// calls and avoids issues with platform-specific ad SDKs on unsupported
161160
// platforms (e.g., AdMob on web).
162161
AdPlatformType.admob: demoAdProvider,
163-
AdPlatformType.local: demoAdProvider,
164162
AdPlatformType.demo: demoAdProvider,
165163
};
166164
} else {
167-
logger.fine('Using AdMobAdProvider and LocalAdProvider.');
165+
logger.fine('Using Real AdProviders.');
168166
// For development and production environments (non-web), use real ad providers.
169167
adProviders = {
170168
// AdMob provider for Google Mobile Ads.
171169
AdPlatformType.admob: AdMobAdProvider(logger: logger),
172-
// Local ad provider for custom/backend-served ads.
173-
AdPlatformType.local: LocalAdProvider(
174-
localAdRepository: DataRepository<LocalAd>(
175-
dataClient: DataApi<LocalAd>(
176-
httpClient: httpClient,
177-
modelName: 'local_ad',
178-
fromJson: LocalAd.fromJson,
179-
toJson: LocalAd.toJson,
180-
logger: logger,
181-
),
182-
),
183-
logger: logger,
184-
),
185170
// The demo ad platform is not available in non-demo/non-web environments.
186171
// If AdService attempts to access it, it will receive null, which is
187172
// handled by AdService's internal logic (logging a warning).
@@ -226,7 +211,6 @@ Future<Widget> bootstrap(
226211
late final DataClient<UserContentPreferences> userContentPreferencesClient;
227212
late final DataClient<UserAppSettings> userAppSettingsClient;
228213
late final DataClient<User> userClient;
229-
late final DataClient<LocalAd> localAdClient;
230214
if (appConfig.environment == app_config.AppEnvironment.demo) {
231215
logger.fine('Using in-memory clients for all data repositories.');
232216
headlinesClient = DataInMemory<Headline>(
@@ -296,12 +280,6 @@ Future<Widget> bootstrap(
296280
getId: (i) => i.id,
297281
logger: logger,
298282
);
299-
localAdClient = DataInMemory<LocalAd>(
300-
toJson: LocalAd.toJson,
301-
getId: (i) => i.id,
302-
initialData: localAdsFixturesData,
303-
logger: logger,
304-
);
305283
} else if (appConfig.environment == app_config.AppEnvironment.development) {
306284
logger.fine('Using API clients for all data repositories (Development).');
307285
headlinesClient = DataApi<Headline>(
@@ -353,13 +331,6 @@ Future<Widget> bootstrap(
353331
toJson: (user) => user.toJson(),
354332
logger: logger,
355333
);
356-
localAdClient = DataApi<LocalAd>(
357-
httpClient: httpClient,
358-
modelName: 'local_ad',
359-
fromJson: LocalAd.fromJson,
360-
toJson: LocalAd.toJson,
361-
logger: logger,
362-
);
363334
} else {
364335
logger.fine('Using API clients for all data repositories (Production).');
365336
// Default to API clients for production
@@ -412,20 +383,12 @@ Future<Widget> bootstrap(
412383
toJson: (user) => user.toJson(),
413384
logger: logger,
414385
);
415-
localAdClient = DataApi<LocalAd>(
416-
httpClient: httpClient,
417-
modelName: 'local_ad',
418-
fromJson: LocalAd.fromJson,
419-
toJson: LocalAd.toJson,
420-
logger: logger,
421-
);
422386
}
423387
logger.fine('All data clients instantiated.');
424388

425389
final headlinesRepository = DataRepository<Headline>(
426390
dataClient: headlinesClient,
427391
);
428-
final localAdRepository = DataRepository<LocalAd>(dataClient: localAdClient);
429392
final topicsRepository = DataRepository<Topic>(dataClient: topicsClient);
430393
final countriesRepository = DataRepository<Country>(
431394
dataClient: countriesClient,
@@ -518,7 +481,6 @@ Future<Widget> bootstrap(
518481
feedDecoratorService: feedDecoratorService,
519482
inlineAdCacheService: inlineAdCacheService,
520483
feedCacheService: feedCacheService,
521-
localAdRepository: localAdRepository,
522484
navigatorKey: navigatorKey,
523485
),
524486
);

0 commit comments

Comments
 (0)