trackWidgetStart method

Future<void> trackWidgetStart(
  1. String widgetName
)

Tracks when a widget has started.

May throw Exception on native platform contingency.

Implementation

Future<void> trackWidgetStart(String widgetName) async {
  try {
    final startDate = DateTime.now().millisecondsSinceEpoch;
    final trackedWidget =
        TrackedWidget(widgetName: widgetName, startDate: startDate);

    final params = {
      'widgetName': trackedWidget.widgetName,
      'startDate': trackedWidget.startDate,
      'endDate': trackedWidget.endDate,
    };

    final uuid = await channel.invokeMethod<String>('trackPageStart', params);
    trackedWidget.uuidString = uuid!;

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