onScreenview static method
Triggers a screen view event in the app. The event can be a load, unload or visit event.
The tlType
argument should be a string representing the type of screen transition:
- "LOAD" for when the screen is being loaded,
- "UNLOAD" for when the screen is being unloaded,
- "VISIT" for when the screen is visited.
The layoutParameters
is an optional list of maps where each map has a String
key and dynamic value.
It can be used to pass extra parameters related to the screen transition.
Throws a TealeafException if the provided tlType
argument is not one of the allowed types
or when the native platform throws a PlatformException.
Implementation
static Future<void> onScreenview(String tlType, String logicalPageName,
[List<Map<String, dynamic>>? layoutParameters]) async {
try {
if (["LOAD", "UNLOAD", "VISIT"].contains(tlType)) {
// Send the screen view event to -the native side
return await _channel.invokeMethod('screenview', <dynamic, dynamic>{
'tlType': tlType,
'logicalPageName': logicalPageName,
'layoutParameters': layoutParameters
});
}
throw TealeafException.create(
code: 2, msg: 'Illegal screenview transition type');
} on PlatformException catch (pe) {
throw TealeafException(pe,
msg: 'Unable to process screen view (update) message!');
}
}