startTimer static method

Future<void> startTimer(
  1. String name
)

Times events by using custom timers that span across multiple methods.

Timer names can contain only alphanumeric characters and spaces.

Method might throw Exception.

Future<void> doCheckout() async {
 final checkoutTimerName = "Time spent on checkout";

 try {
   await Instrumentation.startTimer(checkoutTimerName);
   await someCheckoutService();
   await someOtherLongTask();
 } finally {
   await Instrumentation.stopTimer(checkoutTimerName);
 }
}

Implementation

static Future<void> startTimer(String name) async {
  try {
    await channel.invokeMethod<void>('startTimer', name);
  } on PlatformException catch (e) {
    throw Exception(e.details);
  }
}