Flutter Integration for iQIYI Live Broadcast Assistant (Android & iOS)
The iQIYI Live Broadcast Assistant adopts Flutter to replace native UI layers on Android and iOS, integrating via Flutter fragments or views and AAR packages on Android and through Podfile, Xcode scripts, and FlutterViewController on iOS, achieving near‑native performance and enabling future migration of more screens to a single codebase.
The iQIYI Live Broadcast Assistant (also known as "Live Machine") is a mobile platform that provides streamers with diverse live‑stream content, including game streaming, beauty camera streaming, and mini‑theater streaming. The Android and iOS clients share a similar three‑layer architecture: an APP layer for UI and interaction, an SDK layer that calls native libraries, and a native .so layer that implements core streaming and playback functions in C.
To increase code reuse and reduce development cost, the team decided to adopt a cross‑platform framework. Flutter was chosen because it breaks away from native widget constraints, uses a layered architecture (Framework + Engine), renders with Skia (the same engine behind Chrome), and offers near‑native performance together with a fast Hot‑Reload development cycle.
Flutter’s architecture consists of a Framework layer that provides widgets, animations, etc., and an Engine layer written in C/C++ that handles rendering, text layout, and platform channels.
Android Integration
Two integration methods are demonstrated:
Using a Flutter Fragment: Flutter.createFragment("settings") Using a Flutter View:
Flutter.createView(getActivity(), getLifecycle(), "settings");Routing is handled by passing a route string when creating the fragment or view. The Flutter side matches the route in main() and returns the appropriate widget:
void main() { runApp(_widgetForRoute(window.defaultRouteName)); } Widget _widgetForRoute(String route) { switch (route) { case 'settings': return MaterialApp(home: SettingsPage()); /* ... */ } }For Gradle‑based module integration, the following snippet is added to settings.gradle:
setBinding(new Binding([gradle: this]))
evaluate(new File(settingsDir.parentFile, 'flutter_liveshow/.android/include_flutter.groovy'))Alternatively, the Flutter module can be packaged as an AAR. The steps are:
Run ./gradlew Flutter:assembleRelease in the .android directory to generate the AAR.
Copy the generated AAR into the Android app’s libs folder and add it as a dependency.
Include the required icudtl.dat resource in the app bundle (a known issue in the current Flutter version).
iOS Integration
In the Podfile, the Flutter module path is defined and the helper script is evaluated:
flutter_application_path = '../flutter_liveshow/'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)The script adds necessary Flutter pods. After editing the Podfile, run pod install.
In Xcode, a new Run Script Phase is added under Build Phases with the following commands to build and embed the Flutter engine:
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" build
"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embedA user‑defined build setting FLUTTER_ROOT must also be added.
To host Flutter pages, the AppDelegate.swift imports Flutter and registers plugins, then creates a FlutterViewController with the desired initial route:
import Flutter
import FlutterPluginRegistrant
@UIApplicationMain
class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
let flutterVC = FlutterViewController()
flutterVC.setInitialRoute("settings")
navigationController?.pushViewController(flutterVC, animated: true)Results and Future Plans
After integration, the Flutter‑based pages perform as smoothly as native pages, providing a seamless user experience. The team plans to migrate more list and detail pages to Flutter, maintain a reusable Flutter component library, and gradually achieve a single codebase that runs on both Android and iOS.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
