initAsync method

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

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.
  _rebuildAllowed = false;

  for (final con in _controllerList) {
    //
    try {
      init = await con.initAsync();
    } catch (e) {
      //
      final details = FlutterErrorDetails(
        exception: e,
        stack: e is Error ? e.stackTrace : null,
        library: 'mvc_pattern.dart',
        context: ErrorDescription('${con.runtimeType}.initAsync'),
      );
      // To cleanup and recover resources.
      init = con.onAsyncError(details);

      if (!init) {
        // If the error is not handled here. To be handled above.
        rethrow;
      }
    }
  }
  _rebuildAllowed = true;

  /// No 'setState()' functions are necessary
  _rebuildRequested = false;
  return init;
}