data property

JsonWidgetData get data

Implementation

JsonWidgetData get data {
  if (_data == null) {
    var data = _registry.getValue(_key);

    if (data is! JsonWidgetData) {
      throw Exception(
        'Unable to find JsonWidgetData for [$_key] on the registry',
      );
    }

    // It's an error for two exact JsonWidgetData objects to be in two places
    // on the tree.  To avoid that, we recreate the data object to effectively
    // clone it so it's a copy that gets placed on the tree and not the exact
    // widget.  Plus, this way the widget picks up any current dynamic values
    // rather than the outdated ones it might have been set up with.
    _data = data.recreate();
  }
  return _data!;
}