buildWidget static method
Widget
buildWidget(
- String taskId,
- String rootId,
- UIComponent component, {
- String? type,
- required Map<
String, dynamic> assets, - String? fontFamily = "Inter",
- required String assetUrl,
- dynamic callBack()?,
- double? width,
- double? height,
- GlobalKey<
State< ? key,StatefulWidget> > - String? id,
- int? index,
- String? parentHeight,
- String? parentWidth,
- String? stepOrientation,
Implementation
static Widget buildWidget(
String taskId,
String rootId,
UIComponent component, {
String? type,
required Map<String, dynamic> assets,
String? fontFamily = "Inter",
required String assetUrl,
Function(
String?,
String?,
String?,
)? callBack,
double? width,
double? height,
GlobalKey? key,
String? id,
int? index,
String? parentHeight,
String? parentWidth,
String? stepOrientation,
}) {
switch (component.type) {
case 4:
return UIButton(
rootId: rootId,
taskId: taskId,
index: index,
height: height,
key: key,
fontFamily: fontFamily,
componentData: component,
buttonClickHandler: callBack,
width: width,
);
case 1:
return UIText(
rootId: rootId,
taskId: taskId,
index: index,
key: key,
width: width,
height: height,
fontFamily: fontFamily,
componentData: component,
textClickHandler: (id) {
log('Text clicked with text: $id');
},
);
case 2:
var status = 1;
if (CentralDataRepository.getInstance(taskId)!.subTasks != null &&
CentralDataRepository.getInstance(taskId)!.subTasks!.isNotEmpty) {
status = CentralDataRepository.getInstance(taskId)
?.subTasks
?.elementAt(index ?? 0)?["status"] ??
1;
}
final RegExp videoExtensionsRegExp =
RegExp(r'\.(mp4|webm|mov|avi)(\?.*)?$');
if (videoExtensionsRegExp
.hasMatch(component.properties![status - 1].asset!)) {
return UIVideo(
rootId: rootId,
taskId: taskId,
index: index,
key: key,
componentData: component,
assetUrl: assetUrl,
assets: assets,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
videoClickHandler: (id) {
log('Video clicked with id: $id');
},
);
} else {
return UIImage(
rootId: rootId,
taskId: taskId,
index: index,
key: key,
componentData: component,
assetUrl: assetUrl,
assets: assets,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
imageClickHandler: (id) {
log('Image clicked with id: $id');
},
);
}
case 15:
return UIContainer(
rootId: rootId,
type: type,
taskId: taskId,
parentHeight: parentHeight,
parentWidth: parentWidth,
index: index,
height: height,
width: width,
key: key,
assets: assets,
assetUrl: assetUrl,
componentData: component,
children: component.widgets,
callBack: callBack,
);
case 16:
return UIList(
rootId: rootId,
taskId: taskId,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
index: index,
component: component,
assets: assets,
assetUrl: assetUrl,
);
case 20:
return Container(
height: 300,
width: 300,
color: Colors.red,
);
case 28:
return UISwipe(
rootId: rootId,
taskId: taskId,
index: index,
key: key,
fontFamily: fontFamily,
swipeUpComponent: component,
callBack: callBack,
);
case 29:
return UITimer(
taskId: taskId,
index: index,
key: key,
data: component,
fontFamily: fontFamily,
);
case 34:
// return UIListItem(
// taskId: taskId,
// parentHeight: parentHeight,
// parentWidth: parentWidth,
// height: height,
// width: width,
// index: index,
// component: component,
// children: component.widgets!,
// );
return UIContainer(
rootId: rootId,
taskId: taskId,
parentHeight: parentHeight,
parentWidth: parentWidth,
index: index,
height: height,
width: width,
key: key,
assets: assets,
assetUrl: assetUrl,
componentData: component,
children: component.widgets,
callBack: callBack,
);
case 35:
return UIScrollContainer(
rootId: rootId,
taskId: taskId,
parentHeight: parentHeight,
parentWidth: parentWidth,
index: index,
height: height,
width: width,
key: key,
assets: assets,
assetUrl: assetUrl,
component: component,
);
case 36:
return UIStepContainer(
rootId: rootId,
taskId: taskId,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
index: index,
component: component,
);
case 37:
return UIStepItem(
rootId: rootId,
taskId: taskId,
stepOrientation: stepOrientation,
height: height,
width: width,
parentWidth: parentWidth,
parentHeight: parentHeight,
id: id,
index: index,
component: component,
children: component.widgets!,
);
case 38:
return UIStep(
rootId: rootId,
taskId: taskId,
stepOrientation: stepOrientation,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
index: index,
component: component,
children: component.widgets!,
);
case 39:
return UIProgress(
rootId: rootId,
taskId: taskId,
component: component,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
index: index,
);
case 41:
return UICopyButton(
rootId: rootId,
taskId: taskId,
component: component,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
index: index,
);
case 42:
return UIShareButton(
rootId: rootId,
taskId: taskId,
component: component,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
index: index,
assets: assets,
);
case 43:
return UIScratchCard(
component: component,
taskId: taskId,
rootId: rootId,
index: index,
assetUrl: assetUrl,
assets: assets,
parentHeight: parentHeight,
parentWidth: parentWidth,
height: height,
width: width,
);
default:
return const SizedBox.shrink();
}
}