Setup
Use AATKit with Flutter app
Usage of Flutter Binding in your project
Basing on this project, you can integrate AATKit within your Flutter app. To achieve it, please follow the instructions below.
Dart integration
All needed dart files are included to the flutter-binding/lib/aatkit directory. Copy and paste this folder to the lib directory in your project.
Android integration
Find
flutter-binding/android/app/src/main/kotlin/com/addapttr/flutter_bindingdirectory.There are Kotlin files required by the native Android project to let AATKit works correctly. Copy the files from the list:
AATKitBinding.kt
AATKitListener.kt
NativeBannerView.kt
NativeViewFactory.ktPaste copied files to the
flutter-binding/android/app/src/main/kotlin/your/package/namedirectory in your project.Edit
configureFlutterEnginemethod in your Android project'sMainActivityclass, like:
class MainActivity: FlutterActivity() {
companion object {
const val BANNER_VIEW_TYPE = "<aatkit-banner-view>"
}
var aatKitBinding: AATKitBinding? = null
...
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
...
//Add code below to your configureFlutterEngine to allow calling AATKitBinding methods from
//dart code.
aatKitBinding = AATKitBinding(application, this)
val methodChannel = MethodChannel(
flutterEngine.dartExecutor.binaryMessenger,
AATKitBinding.AATKIT_CHANNEL
)
aatKitBinding?.handleMethodChannelCalls(methodChannel)
//Add code below to your configureFlutterEngine to allow creating banner widget
flutterEngine
.platformViewsController
.registry
.registerViewFactory(BANNER_VIEW_TYPE, NativeViewFactory(methodChannel))
}
...
override fun onResume() {
super.onResume()
aatKitBinding?.onActivityResume()
}
override fun onPause() {
super.onPause()
aatKitBinding?.onActivityPause()
}
}iOS integration
Find
flutter-binding/ios/Runnerdirectory.There are Swift files required by the native iOS project to let AATKit works correctly. Copy the files from the list:
AATKitBinding.swift
AATKitDelegate.swift
AATKitNativeBannerView.swift
AATKitNativeViewFactory.swiftPaste copied files to the
flutter-binding/ios/Runnerdirectory in your project.Edit application
didFinishLaunchingWithOptionsmethod in your iOS project'sAppDelegateclass, like:
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
if let controller = window?.rootViewController as? FlutterViewController {
let methodChannel = FlutterMethodChannel(name: AATKitBinding.channel, binaryMessenger: controller.binaryMessenger)
let binding = AATKitBinding(flutterViewController: controller)
binding.handleMethodChannelCalls(methodChannel: methodChannel)
weak var registrar = self.registrar(forPlugin: "aatkit-binding")
let factory = AATKitNativeViewFactory(messenger: registrar!.messenger(), methodChannel: methodChannel)
self.registrar(forPlugin: "<aatkit-binding>")!.register(
factory,
withId: "<aatkit-banner-view>")
}
...
}
}Last updated