getMicroBoardApps property
List<MicroBoardApp>
getMicroBoardApps
Implementation
List<MicroBoardApp> get getMicroBoardApps {
if (MicroHost.microApps.isNotEmpty) {
final microBoardApps = MicroHost.microApps.map((currentMicroApp) {
String microAppRoute = '';
String microPageRoute = '';
String parentName = '';
if (currentMicroApp is MicroAppWithBaseRoute) {
microAppRoute = currentMicroApp.baseRoute.baseRoute.route;
} else if (currentMicroApp is IMicroAppBaseRoute) {
microAppRoute =
(currentMicroApp as IMicroAppBaseRoute).baseRoute.route;
}
final routes = currentMicroApp.pages.map((e) {
if (e.route.isNotEmpty) {
final splited =
e.route.split(MicroAppPreferences.config.pathSeparator);
if (splited.isNotEmpty) {
// If there is no baseRoute, infer the baseroute if all routes have the first segment identical
if (microAppRoute.isEmpty &&
currentMicroApp.pages.every(
(element) => element.route.startsWith(splited.first))) {
microAppRoute = splited.first;
}
microPageRoute = e.route;
}
}
parentName = e.pageBuilder.runtimeType.toString();
if (parentName == 'PageBuilder<Widget>') {
parentName = '';
} else {
parentName = parentName.replaceFirst('PageBuilder<', '');
parentName =
parentName.replaceFirst('>', '', parentName.lastIndexOf('>'));
}
return MicroBoardRoute(
route: microPageRoute,
widget: parentName,
description: e.description);
}).toList();
final handlers = microAppEventController.handlers.entries
.where((element) => element.key.parentName == currentMicroApp.name)
.map((entry) {
String handlerType = entry.key.runtimeType.toString();
if (handlerType == 'MicroAppEventHandler<dynamic>') {
handlerType = Constants.notTyped;
} else {
handlerType = handlerType.replaceFirst('MicroAppEventHandler', '');
}
return MicroBoardHandler(
type: handlerType,
channels: entry.key.channels,
parentName: parentName);
}).toList();
return MicroBoardApp(
type: currentMicroApp.runtimeType.toString(),
name: currentMicroApp.name,
description: currentMicroApp.description,
route: microAppRoute,
pages: routes,
handlers: handlers,
);
}).toList();
return microBoardApps;
}
return [];
}