initialize method

  1. @protected
  2. @mustCallSuper
  3. @visibleForTesting
FutureOr<void> initialize()

Initializes something.

Will throw if before was called ensureInitialized:

  1. There is already initialization in progress.
  2. This object is already initialized.

For protected use only, and only for ensureInitialized.

BTW, u are free to use it as u want.

Implementation

@protected
@mustCallSuper
@visibleForTesting
FutureOr<void> initialize() {
  assert((){
    if (_isInitializingAssertionDisabled) {
      _isInitializingAssertionDisabled = false;
      return true;
    }
    return _state != _initializingState;
  }(),
    'There is already initialization in progress',
  );
  assert(
      _state != _initializedState,
      '$_className has been initialized already. '
      'Use $_className.ensureInitialized to initialize it safely.');
}