addComponent function

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

Implementation

Future<void> addComponent(BuildContext context, AppModel app,
    String? componentName, 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 {
      component.editor.createNewComponent(app, context, editorFeedback);
    }
  }
}