destructure method

Map<String, dynamic> destructure()

Implementation

Map<String, dynamic> destructure() {
  if (_destructureFails.contains(runtimeType)) {
    throw "Destructure method not found for $runtimeType";
  }
  int? i = _destructureMethodCache[runtimeType];
  if (i != null) return _destructures[i](this);

  for (Map<String, dynamic> Function(dynamic) m in _destructures) {
    try {
      Map<String, dynamic> r = m(this);
      _destructureMethodCache[runtimeType] = _destructures.indexOf(m);
      return r;
    } catch (ignored) {}
  }

  _destructureFails.add(runtimeType);
  throw "Destructure method not found for $runtimeType";
}