logScreenLayout static method

Future<void> logScreenLayout(
  1. String logicalPageName
)

Logs the layout of the screen and captures a Tealeaf screen view event.

This function logs the widgets on the screen using the logWidgetTree function and then calls the Tealeaf screen capture API to capture the screen load event. The captured event includes the logical page name provided as logicalPageName.

Throws a TealeafException if there is an error during the process, including if there is an issue with the Tealeaf plugin or platform-specific errors.

Example usage:

await logScreenLayout('HomePage');

Parameters:

  • logicalPageName: The logical name of the page/screen to be used in the Tealeaf event.

Throws:

Implementation

static Future<void> logScreenLayout(String logicalPageName) async {
  try {
    /// First logs the screen widgets, then call Tealeaf screen capture API
    logWidgetTree().then((result) {
      /// Captures screen load event, with page name
      PluginTealeaf.onScreenview("LOAD", logicalPageName, result);
    }).catchError((error) {
      tlLogger.e('Error: $error');
    });
  } on PlatformException catch (pe) {
    throw TealeafException(pe, msg: 'Unable to process screen capture');
  }
}