InitializedResult constructor

InitializedResult(
  1. Map resultMap
)

Creates an InitializedResult by parsing a result map.

The resultMap must contain the keys for initializing result and message. If required keys are missing, an assertion error is thrown.

Implementation

InitializedResult(Map<dynamic, dynamic> resultMap) {
  try {
    _checkKeyExists(resultMap, _initializedResultKey);
    _checkKeyExists(resultMap, _initializedResultMessageKey);
  } on FormatException catch (e) {
    print("Initialization failed: ${e.message}");
    // Set default values in case of failure
    result = false;
    message = missingKeys;
  }

  result = resultMap[_initializedResultKey] ?? false;
  message = resultMap[_initializedResultMessageKey] ?? missingKeys;
}