initAsync method

  1. @override
  2. @mustCallSuper
Future<bool> initAsync()
override

Asynchronous operations must complete successfully.

Implementation

@override
@mustCallSuper
Future<bool> initAsync() async {
  //
  bool init = true;
  // No 'setState()' functions are allowed to fully function at this point.
  _setStateAllowed = false;

  for (final con in _controllerList) {
    //
    try {
      final _init = await con.initAsync();
      if (!_init) {
        // All were not successful.
        init = false;
      }
    } catch (e) {
      //
      final details = FlutterErrorDetails(
        exception: e,
        stack: e is Error ? e.stackTrace : null,
        library: 'state_extended.dart',
        context: ErrorDescription('${con.runtimeType}.initAsync'),
      );
      // To cleanup and recover resources.
      con.onAsyncError(details);
      // Have it handled by an error handler.
      rethrow;
    }
  }
  _setStateAllowed = true;

  /// No 'setState()' functions are necessary
  _setStateRequested = false;

  return init;
}