All Products
Search
Document Center

Application Real-Time Monitoring Service:FAQ about Flutter app integration

Last Updated:Dec 18, 2024

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")
        },
);