fromJson static method

CubitEntity fromJson(
  1. Map<String, dynamic> json
)

Implementation

static CubitEntity fromJson(Map<String, dynamic> json) {
  final states = <ID, CubitStateEntity>{};
  if (json['states'] != null) {
    for (final entry in json['states'].entries) {
      states[entry.key] = CubitStateEntity.fromJson(entry.value);
    }
  }
  final workflows = <ID, WorkflowEntity>{};
  if (json['workflows'] != null) {
    for (final entry in json['workflows'].entries) {
      workflows[entry.key] =
          WorkflowEntity.fromJson(entry.value, getIt<ActionMapper>());
    }
  }
  return CubitEntity(
    id: json['id'],
    name: json['name'],
    initialState: json['initialState'] ?? states.entries.firstOrNull?.key,
    states: states,
    workflows: workflows,
    currentState: json['initialState'] ?? states.entries.firstOrNull?.key,
    stateHistory: const [],
  );
}