getWidget function
Implementation
Widget getWidget(
String widgetType,
Color color, // ✅ Changed to String // ✅ Changed to String
String graphSizeStr,
DateTime referenceTime, // ✅ Changed to String
{String timeWindowStr = 'auto', String tickerTypeStr = 'last', double height = 100, dynamic variable}
) {
variable ??= mockVariable;
// ✅ Convert Strings to Enums
MBTimeWindow? timeWindow = stringToTimeWindow(timeWindowStr);
MBTickerType? tickerType = stringToTickerType(tickerTypeStr);
MBGraphSize? graphSize = stringToGraphSize(graphSizeStr);
// ✅ Provide default values if conversion fails
timeWindow ??= MBTimeWindow.auto;
tickerType ??= MBTickerType.last;
graphSize ??= MBGraphSize.half;
return widgetRegistry[widgetType]?.call(
variable, color, timeWindow, tickerType, graphSize, height, referenceTime) ??
const SizedBox(); // Default to empty if not found
}