component method

Widget component(
  1. BuildContext context,
  2. AppModel app,
  3. String componentName,
  4. String id, {
  5. Map<String, dynamic>? parameters,
  6. Key? key,
})

Implementation

Widget component(
    BuildContext context, AppModel app, String componentName, String id,
    {Map<String, dynamic>? parameters, Key? key}) {
  try {
    var componentConstructor = _registryMap[componentName];
    if (componentConstructor != null) {
      return BlocBuilder(
          bloc: BlocProvider.of<AccessBloc>(context),
          builder: (BuildContext context, accessState) {
            if (accessState is AccessDetermined) {
              return FutureBuilder<dynamic>(
                  future: componentConstructor.getModel(app: app, id: id),
                  builder: (context, snapshot) {
                    if (snapshot.hasData) {
                      var model = snapshot.data;
                      var hasAccess = componentAccessValidation(context,
                          accessState, app, componentName, id, model);
                      if (hasAccess) {
                        return componentConstructor.createNew(
                                key: key,
                                app: app,
                                id: id,
                                parameters: parameters) ??
                            _missingComponent(componentName);
                      } else {
                        return Container();
                      }
                    } else {
                      return Container();
//                return progressIndicator(context);
                    }
                  });
            } else {
              return Center(child: CircularProgressIndicator());
            }
          });
    } else {
      return Container();
    }
  } catch (_) {}
  return _missingComponent(componentName);
}