updateComponent function

Future<void> updateComponent(
  1. BuildContext context,
  2. AppModel app,
  3. String? componentName,
  4. String? componentId,
  5. EditorFeedback editorFeedback,
)

Implementation

Future<void> updateComponent(
    BuildContext context,
    AppModel app,
    String? componentName,
    String? componentId,
    EditorFeedback editorFeedback) async {
  var appId = app.documentID;
  if (componentName == null) {
    openErrorDialog(app, context, '$appId/_error',
        title: 'Problem', errorMessage: 'Component name is null');
  } else {
    var component =
        Apis.apis().getRegistryApi().getComponentSpecs(componentName);
    if (component == null) {
      openErrorDialog(app, context, '$appId/_error',
          title: 'Problem',
          errorMessage: 'Component specs for $componentName not found');
    } else {
      if (componentId == null) {
        openErrorDialog(app, context, '$appId/_error',
            title: 'Problem',
            errorMessage:
                'Component $componentName with ID $componentId does not exist');
      } else {
        component.editor
            .updateComponentWithID(app, context, componentId, editorFeedback);
      }
    }
  }
}