This topic describes common FAQs regarding the integration of Flutter apps with Real User Monitoring (RUM) of Application Real-Time Monitoring Service (ARMS).
What do I do if my business code depends on WidgetsFlutterBinding.ensureInitialized?
When the AlibabaCloudRUM SDK is initialized, you can specify the beforeRunApp callback function in your business code and call the WidgetsFlutterBinding.ensureInitialized method in the function. Since the beforeRunApp callback function is called before the main function runApp, the Flutter app binding is properly initialized before the app runs.
Sample code:
AlibabaCloudRUM().start(
MyApp(),
beforeRunApp: () async =>
{
// Manually call the WidgetsFlutterBinding.ensureInitialized() method.
WidgetsFlutterBinding.ensureInitialized(),
await Dio().request("https://xxxxx.yyy/zzz")
},
);