updatePropsByState static method

Map<String, dynamic> updatePropsByState(
  1. Map<String, dynamic> json,
  2. String stateVariable
)

Implementation

static Map<String, dynamic> updatePropsByState(
  Map<String, dynamic> json,
  String stateVariable,
) {
  debugPrint("Entry Data1 $stateVariable: ${json.toString()}");

  if (!json.containsKey(stateVariable)) {
    return json;
  }

  final updatedJson = Map<String, dynamic>.from(json);
  final stateProps = updatedJson[stateVariable] as Map<String, dynamic>;
  final mainProps = updatedJson['props'] as Map<String, dynamic>;

  stateProps.forEach((key, value) {
    mainProps[key] = value;
  });

  debugPrint("Entry Data2 $stateVariable: ${json.toString()}");
  return updatedJson;
}