trackWidgetEnd method

Future<void> trackWidgetEnd(
  1. String widgetName
)

Tracks when a widget has ended.

If the widget doesn't exist, it doesn't do anything.

May throw Exception on native platform contingency.

Implementation

Future<void> trackWidgetEnd(String widgetName) async {
  try {
    final trackedWidget = trackedWidgets[widgetName];

    if (trackedWidget == null) {
      return;
    }

    final endDate = DateTime.now().millisecondsSinceEpoch;
    trackedWidget.endDate = endDate;

    await channel.invokeMethod<void>('trackPageEnd', trackedWidget.toJson());

    trackedWidgets.remove(trackedWidget.widgetName);
  } on PlatformException catch (e) {
    throw Exception(e.details);
  }
}