toEnd<T> method

Future<T> toEnd<T>(
  1. FutureOr<T> computation()
)

Delays the execution of the given computation until the end of the event loop.

Useful for ensuring that certain computations are executed after the current event loop has completed.

Example:

await Get.toEnd(() async {
  // Some asynchronous computation
});

Implementation

Future<T> toEnd<T>(FutureOr<T> Function() computation) async {
  await Future.delayed(Duration.zero);
  final val = computation();
  return val;
}