Add Adrop to Flutter

Prerequisites

  • Install your preferred editor or IDE.

  • Make sure that your app meets the following requirements:

    • Android:

      • Targets API level 23 (M) or higher

      • Uses Android 6.0 or higher

        • minSdkVersion 23

      • Uses Jetpack (AndroidX), which includes meeting these version requirements:

        • com.android.tools.build:gradle v7.3.0 or later

        • compileSdkVersion 33

      • Kotlin 1.7.10 or higher

    • iOS:

      • iOS 13

      • Swift 5.0

  • Install Flutter for your specific operating system, including the following:

    • Flutter SDK

    • Supporting libraries

    • Platform-specific software and SDKs

  • Sign into Adrop using your email or Google account.


Step 1: Create an Adrop project

Before you can add Adrop to your Flutter app, you need to create an Adrop project to connect to your app.

Step 2: Register your app with Adrop

To use Adrop in your Flutter app, you need to register your app with your Adrop project. Registering your app is often called "adding" your app to your project.

Make sure to enter the package name that your app is actually using. The package name value is case-sensitive, and it cannot be changed for this Adrop Android app after it's registered with your Adrop project.

Using Flutter app builder
  1. Go to the Adrop console.

  2. In the center of the project app page, click the Flutter icon button to launch the setup workflow.

  3. Enter your app's package name in the Flutter package name field.

    • A package name uniquely identifies your app on the device and in the Google Play Store or App Store.

    • A package name is often referred to as an application ID.

    • Be aware that the package name value is case-sensitive, and it cannot be changed for this Adrop Flutter app after it's registered with your Adrop project.

  4. Enter other app information: App nickname.

    • App nickname: An internal, convenience identifier that is only visible to you in the Adrop console

  5. Click Register app and then Android and Apple apps will be created respectively.

Step 3: Add an Adrop configuration file

  1. Download adrop_service.json to obtain your Adrop Android platforms config file.

Step 4: Add Adrop plugin to your app

  1. From your Flutter project directory, run the following command to install the plugin.

flutter pub add adrop_ads_flutter

Step 5: Initialize Adrop in your app

The final step is to add initialization code to your application.

  1. Import the Adrop plugin.

import 'package:adrop_ads_flutter/adrop_ads_flutter.dart';
  1. Also in your lib/main.dart file, initialize Adrop.

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    initialize();
  }

  Future<void> initialize() async {
    // ..
    // true for production
    await Adrop.initialize(false);
  }
}
  1. Rebuild your Flutter application.

flutter run

Next Steps

You're all set! Please register an Ad unit to show ads to users.

Learn how to Create your Ad unit.


(Optional) Troubleshooting

# Add this line to your Podfile
use_frameworks!

# ...
post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|

        #...
        # Add this line to your Podfile
        config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
    end
end

Last updated