Common questions about integrating Flutter apps with Application Real-Time Monitoring Service (ARMS) Real User Monitoring (RUM).
My app calls WidgetsFlutterBinding.ensureInitialized before runApp. How do I handle this with the RUM SDK?
Use the beforeRunApp callback in AlibabaCloudRUM().start(). This callback runs before runApp, so Flutter binding initialization completes before the app starts.
AlibabaCloudRUM().start(
MyApp(),
beforeRunApp: () async =>
{
// Manually call the WidgetsFlutterBinding.ensureInitialized() method.
WidgetsFlutterBinding.ensureInitialized(),
await Dio().request("https://xxxxx.yyy/zzz")
},
);In this example, WidgetsFlutterBinding.ensureInitialized() and an asynchronous HTTP request both run inside beforeRunApp before the app launches.