setData method

dynamic setData(
  1. Map<String, dynamic> data, {
  2. bool refreshState = true,
})

Set the data for the form

Implementation

setData(Map<String, dynamic> data, {bool refreshState = true}) {
  if (data.isEmpty) {
    return;
  }
  data.forEach((key, value) {
    List<MapEntry<String, dynamic>> dataMapEntries = _data.entries
        .where((entry) => entry.key.snakeCase == key.snakeCase)
        .toList();
    if (dataMapEntries.isEmpty) {
      _data[key] = value;
    } else {
      _data[dataMapEntries.first.key] = value;
    }
  });
  if (!refreshState) return;
  NyForm.stateRefresh(stateName);
}