multi_ads 1.1.5 copy "multi_ads: ^1.1.5" to clipboard
multi_ads: ^1.1.5 copied to clipboard

Multiple Ad Network

multi_ads #

A Flutter plugin that combines ad orchestration, reward helpers, API utilities, and anime helper services in one package.

Features #

  • Screen-based and route-based ad flow helpers.
  • Banner and native ad widget helpers.
  • App registration/setup flow with remote config support.
  • Reward helper and builder utilities.
  • Clash Royale API helper methods.
  • Brawl Stars API helper (BrawlStarHelper.officialApi) for proxied official endpoints.
  • Anime helper methods backed by your Jikan cache wrapper.

Installation #

Add to pubspec.yaml:

dependencies:
  multi_ads: ^1.1.2

Install dependencies:

flutter pub get

Import #

import 'package:multi_ads/multi_ads.dart';

Quick Start #

1) Register app and load config #

Use SetupMixin during app startup or splash flow.

class SplashController with SetupMixin {
  Future<void> init(BuildContext context) async {
    await registerApp(
      RegisterAppParameters(
        context: context,
        appVersion: '1.0.0',
        rewardType: '1',
        apiKey: ApiKey(
          androidKey: 'YOUR_ANDROID_KEY',
          iosKey: 'YOUR_IOS_KEY',
        ),
        requiredAdNetworks: const [],
        onComplete: () {
          // Continue app flow
        },
        onError: (error) {
          // Handle setup error
        },
        onUpdateLaunch: (url) {
          // Open update URL
        },
      ),
    );
  }
}

2) Show ads #

MultiAds.showAdBasedOnScreen(context);

MultiAds.showAdBasedOnName(
  context,
  route: 'home',
);

3) Render banner/native widgets #

Widget build(BuildContext context) {
  return Column(
    children: [
      MultiAds.showScreenBasedBanner(context),
      MultiAds.showScreenBasedNative(context),
    ],
  );
}

Anime Helper (Jikan via Cache Wrapper) #

AnimeServices exposes anime endpoint methods such as:

  • getAnimeById
  • getAnimeFullById
  • getAnimeCharacters
  • getAnimeEpisodes
  • getAnimeNews
  • getAnimeReviews
  • getAnimeStreaming
  • getAnimeSearch

Example:

final anime = AnimeServices();

final result = await anime.getAnimeSearch(
  q: 'Naruto',
  page: 1,
  limit: 25,
  sfw: true,
);

Request Behavior #

  • Requests are routed to: [Base Url]
  • The target path is passed as: endpoint=/anime, endpoint=/top/anime, etc.
  • Each request sends: device_public_key header from DeviceMethods().getUserToken().

Brawl Stars helper (BrawlStarHelper) #

BrawlStarHelper forwards requests to your backend’s Brawl Stars proxy, same pattern as Clash Royale’s clashRoyaleOfficialApi: the official API path is passed as a single query parameter named endpoint.

How the request is built #

  • Base URL: {Urls().baseUrl}BrawlStars/api
  • Full request URL shape: {base}BrawlStars/api?endpoint=<your-path>
  • HTTP: GET via ApiHelper.requestWithServerGet, which adds the device_public_key header (see Anime Helper → Request Behavior).

Import #

import 'package:multi_ads/Helpers/Brawlers/brawl_star_helper.dart';
import 'package:multi_ads/Helpers/ApiHelper.dart';

officialApi — what to pass as url #

The url argument is the path fragment your server expects after the Brawl Stars API base (often aligned with Supercell’s official routes).

Goal Typical url examples
Brawlers (list or metadata) brawlers or v1/brawlers — use the shape your proxy documents.
Player profile by in-game tag In-game tags look like #AS000. In the path, # must be URL-encoded as %23, e.g. players/%23AS000 (not raw # in the query string).

Always confirm exact strings with your BrawlStars/api implementation; proxies sometimes expect v1/... prefixes or slightly different segments.

Example #

final brawl = BrawlStarHelper();

// Brawlers (adjust path to match your backend)
brawl.officialApi(
  'brawlers',
  ApiResponse(
    onRequestComplete: (data) {
      // Parse JSON from data
    },
    onRequestError: (error) {
      // Handle error
    },
  ),
);

// Player with tag #AS000 → use %23 for '#'
brawl.officialApi(
  'players/%23AS000',
  ApiResponse(
    onRequestComplete: (data) { /* ... */ },
    onRequestError: (error) { /* ... */ },
  ),
);

To build tags safely in code:

String playerEndpoint(String tagWithHash) {
  final encoded = Uri.encodeComponent(tagWithHash); // # → %23
  return 'players/$encoded';
}
// playerEndpoint('#AS000') → players/%23AS000

Exports #

This package exports:

  • Base/AdClass.dart
  • Base/MultiAds.dart
  • Helpers/MultAdsHooks.dart
  • Widget/reward_builder.dart
  • Helpers/SetupHelper.dart
  • Helpers/ClashRoyaleApi/RoyaleApiHelper.dart
  • features/anime_feature_helpers/service/anime_services.dart
  • common_interface

Platform Support #

  • Android
  • iOS

License #

See LICENSE file in the repository (if present).