lockEvents method Null safety

  1. @protected
Future<void> lockEvents(
  1. Future<void> callback(

    Locks the dispatching of asynchronous events and callbacks until the callback's future completes.

    This causes input lag and should therefore be avoided when possible. It is primarily intended for use during non-user-interactive time such as to allow reassembleApplication to block input while it walks the tree (which it partially does asynchronously).

    The Future returned by the callback argument is returned by lockEvents.


    Future<void> lockEvents(Future<void> Function() callback) {
      final developer.TimelineTask timelineTask = developer.TimelineTask()..start('Lock events');
      assert(callback != null);
      _lockCount += 1;
      final Future<void> future = callback();
      assert(future != null, 'The lockEvents() callback returned null; it should return a Future<void> that completes when the lock is to expire.');
      future.whenComplete(() {
        _lockCount -= 1;
        if (!locked) {
      return future;