getOptionalVariableById<T> method

VariableInfoEntity getOptionalVariableById<T>(
  1. ID id, {
  2. ID? cubitID,
  3. ID? stateID,
})

Implementation

VariableInfoEntity getOptionalVariableById<T>(
  ID id, {
  ID? cubitID,
  ID? stateID,
}) {
  if (cubitID != null && stateID != null) {
    final variableInfo = appCubit.getVariableById(
      cubitID: cubitID,
      stateID: stateID,
      variableID: id,
    );
    assert(
        variableInfo.variable is T, 'Variable with id $id is not of type $T');
    return variableInfo;
  }
  assert(getCurrentStatesVariables[id] != null,
      'Variable with id $id not found');
  assert(getCurrentStatesVariables[id]!.variable is T,
      'Variable with id $id is not of type $T');
  return getCurrentStatesVariables[id]!;
}