Implementation
void nudgeTooltip(
BuildContext context,
Root rootData,
String eventName,
) async {
OverlayEntry? overlayForegroundEntry;
OverlayEntry? overlayBackgroundEntry;
Nudge.getInstance().submit(
taskId: NudgeNudgesUi.taskID!,
response: [
{
"root_id": rootData.id,
"widget_id": rootData.components[NudgeNudgesUi.currentNudgeIndex].id,
"component_id": rootData.components[NudgeNudgesUi.currentNudgeIndex].id,
"answers": [],
"action": "OPENED",
}
],
onSuccessCallback: (data) {
print("Tooltip Opened, $data");
},
onErrorCallback: (error, stacktrace) {
print("Error: $error");
},
);
NudgeNudgesUi.componentName = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.elementId ??
"";
print('Component Name: ${NudgeNudgesUi.componentName}');
String? referenceSize = rootData.rootProps.size;
Size referenceDimensions = Size(
int.parse(referenceSize.split('x')[0]).toDouble(),
int.parse(referenceSize.split('x')[1]).toDouble(),
);
int referenceHeight = referenceDimensions.height.toInt();
int referenceWidth = referenceDimensions.width.toInt();
Size screenSize = MediaQuery.of(context).size;
double screenHeight = screenSize.height;
double screenWidth = screenSize.width;
double scaleHeight = screenHeight / referenceHeight;
double scaleWidth = screenWidth / referenceWidth;
Color fillColor = HexColor.fromHex(
rootData.components[NudgeNudgesUi.currentNudgeIndex].componentProps
.bgColor ??
"#000000",
);
overlayBackgroundEntry = OverlayEntry(
builder: (context) {
return Positioned(
top: 0,
left: 0,
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: GestureDetector(
onTap: () {
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
Nudge.getInstance().submit(
taskId: NudgeNudgesUi.taskID!,
response: [
{
"root_id": rootData.id,
"widget_id":
rootData.components[NudgeNudgesUi.currentNudgeIndex].id,
"component_id":
rootData.components[NudgeNudgesUi.currentNudgeIndex].id,
"answers": [],
"action": "DISMISSED",
}
],
onSuccessCallback: (data) {
print("Tooltip Dismissed, $data");
},
onErrorCallback: (error, stacktrace) {
print("Error: $error");
},
);
},
child: AbsorbPointer(
child: Container(
color: Colors.white.withOpacity(0),
),
),
),
);
},
);
bool isPositionBased = rootData.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps.isPositionBased ??
false;
NudgeProviderState.navigatorKey.currentState?.overlay
?.insert(overlayBackgroundEntry);
WidgetDetails? targetView = NudgeWidgetTracker.findWidgetPositionByLabel(
NudgeNudgesUi.componentName,
scaleWidth,
scaleHeight,
);
if (targetView == null && !isPositionBased) {
overlayBackgroundEntry.remove();
}
final NudgeNudgesUi nudgeNudgesUi = NudgeNudgesUi();
nudgeNudgesUi
.scrollToTargetWidget(targetView?.key, isPositionBased: isPositionBased)
.then(
(value) => Future.delayed(
const Duration(milliseconds: 100),
),
)
.then((value) {
WidgetDetails? targetViewMain =
NudgeWidgetTracker.findWidgetPositionByLabel(
NudgeNudgesUi.componentName,
scaleWidth,
scaleHeight,
);
logger.i("""
Component Height: ${NudgeNudgesUi.componentHeight},
Component Width: ${NudgeNudgesUi.componentWidth},
Component X: ${NudgeNudgesUi.componentX},
Component Y: ${NudgeNudgesUi.componentY}
""");
if (isPositionBased) {
logger.e("Position Based");
NudgeNudgesUi.componentY = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.elementProps!
.y
.roundToDouble() *
scaleHeight;
NudgeNudgesUi.componentX = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.elementProps!
.x
.roundToDouble() *
scaleWidth;
NudgeNudgesUi.componentHeight = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.elementProps!
.height
.roundToDouble() *
scaleHeight;
NudgeNudgesUi.componentWidth = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.elementProps!
.width
.roundToDouble() *
scaleWidth;
logger.i("""
Component Height: ${NudgeNudgesUi.componentHeight},
Component Width: ${NudgeNudgesUi.componentWidth},
Component X: ${NudgeNudgesUi.componentX},
Component Y: ${NudgeNudgesUi.componentY}
""");
} else if (targetViewMain != null) {
NudgeNudgesUi.componentHeight = targetViewMain.height;
NudgeNudgesUi.componentWidth = targetViewMain.width;
NudgeNudgesUi.componentX = targetViewMain.x;
NudgeNudgesUi.componentY = targetViewMain.y;
}
// print(
// 'Component Height: ${NudgeNudgesUi.componentHeight}, Component Width: ${NudgeNudgesUi.componentWidth}, Component X: ${NudgeNudgesUi.componentX}, Component Y: ${NudgeNudgesUi.componentY}',
// );
logger.i(
"isPositionBased: ${rootData.components[NudgeNudgesUi.currentNudgeIndex].componentProps.isPositionBased}",
);
ImageSize imageSize = extractSize(
rootData.rootProps.size,
);
try {
nudgeNudgesUi.heightRatio =
imageSize.height / MediaQuery.of(context).size.height;
nudgeNudgesUi.widthRatio =
imageSize.width / MediaQuery.of(context).size.width;
} catch (e) {
if (kDebugMode) {
print(e);
}
}
double top;
double left;
String tooltipPosition = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.tooltipPosition ??
'top';
String tooltipArrowPosition = rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.tooltipArrow ??
'top';
// tooltipPosition = "left";
// tooltipArrowPosition = "right";
// X position of Tooltip
if (tooltipPosition == "bottom" && tooltipArrowPosition == "center") {
left = NudgeNudgesUi.componentX + NudgeNudgesUi.componentWidth / 2;
} else if (tooltipPosition == "bottom" && tooltipArrowPosition == "left") {
left = NudgeNudgesUi.componentX + NudgeNudgesUi.componentWidth / 2 - 10;
} else if (tooltipPosition == "bottom" && tooltipArrowPosition == "right") {
left = NudgeNudgesUi.componentX - NudgeNudgesUi.componentWidth / 2 + 10;
} else if (tooltipPosition == "top" && tooltipArrowPosition == "center") {
left = NudgeNudgesUi.componentX + NudgeNudgesUi.componentWidth / 2;
} else if (tooltipPosition == "top" && tooltipArrowPosition == "left") {
left = NudgeNudgesUi.componentX + NudgeNudgesUi.componentWidth / 2 - 10;
} else if (tooltipPosition == "top" && tooltipArrowPosition == "right") {
left = NudgeNudgesUi.componentX + NudgeNudgesUi.componentWidth / 2 + 10;
} else if (tooltipPosition == "left") {
left = NudgeNudgesUi.componentX - 10;
} else if (tooltipPosition == "right") {
left = NudgeNudgesUi.componentX + NudgeNudgesUi.componentWidth / 2 + 10;
} else {
left = NudgeNudgesUi.componentY / 2;
}
// Y position of Tooltip
if (tooltipPosition == "bottom" && tooltipArrowPosition == "center") {
top = NudgeNudgesUi.componentY + NudgeNudgesUi.componentHeight;
} else if (tooltipPosition == "bottom" && tooltipArrowPosition == "left") {
top = NudgeNudgesUi.componentY + NudgeNudgesUi.componentHeight;
} else if (tooltipPosition == "bottom" && tooltipArrowPosition == "right") {
top = NudgeNudgesUi.componentY + NudgeNudgesUi.componentHeight;
} else if (tooltipPosition == "top" && tooltipArrowPosition == "center") {
top = NudgeNudgesUi.componentY - 10; // Subtracting 30 (height of arrow)
} else if (tooltipPosition == "top" && tooltipArrowPosition == "left") {
top = NudgeNudgesUi.componentY - 10; // Subtracting 30 (height of arrow)
} else if (tooltipPosition == "top" && tooltipArrowPosition == "right") {
top = NudgeNudgesUi.componentY - 10; // Subtracting 30 (height of arrow)
} else if (tooltipPosition == "left") {
top = NudgeNudgesUi.componentY + NudgeNudgesUi.componentHeight / 2;
} else if (tooltipPosition == "right") {
top = NudgeNudgesUi.componentY + NudgeNudgesUi.componentHeight / 2;
} else {
top = NudgeNudgesUi.componentY;
}
Color fillColor = HexColor.fromHex(
rootData.components[NudgeNudgesUi.currentNudgeIndex].componentProps
.bgColor ??
"#000000",
);
print("tooltip position: $tooltipPosition");
overlayForegroundEntry = OverlayEntry(builder: (context) {
return Positioned(
top: top,
left: left,
child: tooltipPosition == 'top' || tooltipPosition == 'bottom'
? Opacity(
opacity: 0,
child: Column(
crossAxisAlignment: () {
if (tooltipArrowPosition == "center") {
return CrossAxisAlignment.center;
} else if (tooltipArrowPosition == "left") {
return CrossAxisAlignment.start;
} else if (tooltipArrowPosition == "right") {
return CrossAxisAlignment.end;
} else {
return CrossAxisAlignment.center;
}
}(),
children: [
if (tooltipPosition == "bottom")
Padding(
padding: const EdgeInsets.only(
left: 8.0,
right: 8.0,
),
child: CustomPaint(
size: const Size(20, 10), // Set the size explicitly
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.up,
),
),
),
UIPage(
taskId: NudgeNudgesUi.taskID!,
key: nudgeNudgesUi.contentKey,
nudgeProps: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.toJson(),
type: () {
if (rootData.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps.orientation ==
"vertical") {
return 20;
} else {
return 21;
}
}(),
json: rootData
.components[NudgeNudgesUi.currentNudgeIndex].widgets!,
assetUrl: assetUrl,
assets: Nudge.assets,
),
if (tooltipPosition == "top")
Padding(
padding: EdgeInsets.only(
left: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.roundness!
.toDouble(),
right: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.roundness!
.toDouble(),
),
child: CustomPaint(
size: const Size(20, 10),
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.down,
),
),
),
],
),
)
: Opacity(
opacity: 0,
child: Row(
mainAxisAlignment: () {
if (tooltipArrowPosition == "center") {
return MainAxisAlignment.center;
} else if (tooltipArrowPosition == "left") {
return MainAxisAlignment.start;
} else if (tooltipArrowPosition == "right") {
return MainAxisAlignment.end;
} else {
return MainAxisAlignment.center;
}
}(),
children: [
if (tooltipPosition == "right")
Padding(
padding: const EdgeInsets.only(
top: 0.0,
bottom: 0.0,
right: 10,
),
child: CustomPaint(
size: const Size(10, 20), // Set the size explicitly
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.left,
),
),
),
UIPage(
taskId: NudgeNudgesUi.taskID!,
key: nudgeNudgesUi.contentKey,
nudgeProps: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.toJson(),
type: () {
if (rootData.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps.orientation ==
"vertical") {
return 20;
} else {
return 21;
}
}(),
json: rootData
.components[NudgeNudgesUi.currentNudgeIndex].widgets!,
assetUrl: assetUrl,
assets: Nudge.assets,
),
if (tooltipPosition == "left")
Padding(
padding: const EdgeInsets.only(
top: 0.0,
bottom: 0.0,
right: 10,
),
child: CustomPaint(
size: const Size(10, 20), // Set the size explicitly
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.right,
),
),
),
],
),
),
);
});
NudgeProviderState.navigatorKey.currentState?.overlay
?.insert(overlayForegroundEntry!);
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
if (nudgeNudgesUi.contentKey.currentContext != null) {
NudgeNudgesUi.tooltipContainerHeight =
nudgeNudgesUi.contentKey.currentContext!.size!.height;
NudgeNudgesUi.tooltipContainerWidth =
nudgeNudgesUi.contentKey.currentContext!.size!.width;
double newTop = top;
double newLeft = left;
print(
"Tooltip Position: $tooltipPosition, Tooltip Arrow Position: $tooltipArrowPosition");
// tooltipPosition = "left";
// New Left Position of Tool Tip
if (tooltipPosition == "bottom" && tooltipArrowPosition == "center") {
newLeft = left - NudgeNudgesUi.tooltipContainerWidth / 2;
} else if (tooltipPosition == "bottom" &&
tooltipArrowPosition == "left") {
newLeft = left - 10;
} else if (tooltipPosition == "bottom" &&
tooltipArrowPosition == "right") {
newLeft = left - NudgeNudgesUi.tooltipContainerWidth / 2 - 10;
} else if (tooltipPosition == "top" &&
tooltipArrowPosition == "center") {
newLeft = left - NudgeNudgesUi.tooltipContainerWidth / 2;
} else if (tooltipPosition == "top" && tooltipArrowPosition == "left") {
newLeft = left - 10;
} else if (tooltipPosition == "top" &&
tooltipArrowPosition == "right") {
newLeft = left - NudgeNudgesUi.tooltipContainerWidth + 10;
} else if (tooltipPosition == "left") {
newLeft = left - NudgeNudgesUi.tooltipContainerWidth;
} else if (tooltipPosition == "right") {
newLeft = left +
NudgeNudgesUi.tooltipContainerWidth / 2 -
NudgeNudgesUi.componentWidth / 2 +
10.0;
} else {
newLeft = left;
}
// New Top Position of Tool Tip
if (tooltipPosition == "bottom" && tooltipArrowPosition == "center") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top - NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else if (tooltipPosition == "bottom" &&
tooltipArrowPosition == "left") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top - NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else if (tooltipPosition == "bottom" &&
tooltipArrowPosition == "right") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top - NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else if (tooltipPosition == "top" &&
tooltipArrowPosition == "center") {
// print("Offset: ${NudgeKeyUtility.offset} ");
if (NudgeKeyUtility.offset >= 0) {
newTop = top -
NudgeNudgesUi.tooltipContainerHeight -
NudgeKeyUtility.offset;
} else {
newTop = top - NudgeNudgesUi.tooltipContainerHeight;
}
} else if (tooltipPosition == "top" && tooltipArrowPosition == "left") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top -
NudgeNudgesUi.tooltipContainerHeight -
NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else if (tooltipPosition == "top" &&
tooltipArrowPosition == "right") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top -
NudgeNudgesUi.tooltipContainerHeight -
NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else if (tooltipPosition == "left") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top -
NudgeNudgesUi.tooltipContainerHeight / 2 -
NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else if (tooltipPosition == "right") {
if (NudgeKeyUtility.offset >= 0) {
newTop = top -
NudgeNudgesUi.tooltipContainerHeight / 2 -
NudgeKeyUtility.offset;
} else {
newTop = top;
}
} else {
newTop = top;
}
overlayForegroundEntry?.remove();
print(
"tooltip container width : ${NudgeNudgesUi.tooltipContainerWidth}");
overlayForegroundEntry = OverlayEntry(builder: (context) {
return Positioned(
top: newTop,
left: newLeft,
child: tooltipPosition == 'top' || tooltipPosition == 'bottom'
? Column(
crossAxisAlignment: () {
if (tooltipArrowPosition == "center") {
return CrossAxisAlignment.center;
} else if (tooltipArrowPosition == "left") {
return CrossAxisAlignment.start;
} else if (tooltipArrowPosition == "right") {
return CrossAxisAlignment.end;
} else {
return CrossAxisAlignment.center;
}
}(),
children: [
if (tooltipPosition == "bottom")
Padding(
padding: const EdgeInsets.only(
left: 16.0,
right: 16.0,
),
child: CustomPaint(
size: const Size(20, 10), // Set the size explicitly
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.up,
),
),
),
UIPage(
taskId: NudgeNudgesUi.taskID!,
width: NudgeNudgesUi.tooltipContainerWidth -
(rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.padding
.left) -
(rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.padding
.right),
callBack: (widgetId, target, clickType) {
Nudge.getInstance().submit(
taskId: NudgeNudgesUi.taskID!,
response: [
{
"root_id": rootData.id,
"widget_id": rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.id,
"component_id": rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.id,
"answers": [],
"action": "CTA_CLICKED",
}
],
onSuccessCallback: (data) {
print("Tooltip CTA Clicked, $data");
},
onErrorCallback: (error, stacktrace) {
print("Error: $error");
},
);
print(clickType);
if (clickType == "DEEP_LINK") {
_launchUrl(target!);
} else if (clickType == "EXTERNAL_URL") {
_launchUrl(target!);
} else if (clickType == "NEXT_NUDGE") {
print(NudgeNudgesUi.currentNudgeIndex);
print(NudgeNudgesUi.nudgesLength);
if (NudgeNudgesUi.currentNudgeIndex ==
NudgeNudgesUi.nudgesLength - 1) {
overlayBackgroundEntry?.remove();
overlayForegroundEntry?.remove();
return;
}
print("Next Nudge");
NudgeNudgesUi.currentNudgeIndex++;
print(
"Next Nudge Index: ${NudgeNudgesUi.currentNudgeIndex}, type : ${rootData.components[NudgeNudgesUi.currentNudgeIndex].componentProps.name}");
if (rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.type ==
"spotlight") {
print("Spotlight");
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
nudgeSpotlight(context, rootData, eventName);
} else if (rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.type ==
"coachmark") {
print("Coachmark");
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
nudgeCoachMark(context, rootData, eventName);
} else if (rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.type ==
"tooltip") {
print("Tooltip");
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
nudgeTooltip(context, rootData, eventName);
}
} else {
overlayBackgroundEntry?.remove();
overlayForegroundEntry?.remove();
}
},
key: nudgeNudgesUi.contentKey,
nudgeProps: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.toJson(),
type: () {
if (rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.orientation ==
"vertical") {
return 20;
} else {
return 21;
}
}(),
json: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.widgets!,
assetUrl: assetUrl,
assets: Nudge.assets,
),
if (tooltipPosition == "top")
Padding(
padding: EdgeInsets.only(
left: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.roundness!
.toDouble(),
right: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.roundness!
.toDouble(),
),
child: CustomPaint(
size: const Size(20, 10),
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.down,
),
),
),
],
)
: Row(
mainAxisAlignment: () {
if (tooltipArrowPosition == "center") {
return MainAxisAlignment.center;
} else if (tooltipArrowPosition == "left") {
return MainAxisAlignment.start;
} else if (tooltipArrowPosition == "right") {
return MainAxisAlignment.end;
} else {
return MainAxisAlignment.center;
}
}(),
children: [
if (tooltipPosition == "right")
Padding(
padding: const EdgeInsets.only(
top: 0.0,
bottom: 0.0,
left: 10,
),
child: CustomPaint(
size: const Size(10, 20), // Set the size explicitly
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.left,
),
),
),
UIPage(
taskId: NudgeNudgesUi.taskID!,
width: NudgeNudgesUi.tooltipContainerWidth -
(rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.padding
.left) -
(rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.padding
.right),
callBack: (widgetId, target, clickType) {
clickType = "NEXT_NUDGE";
Nudge.getInstance().submit(
taskId: NudgeNudgesUi.taskID!,
response: [
{
"root_id": rootData.id,
"widget_id": rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.id,
"component_id": rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.id,
"answers": [],
"action": "CTA_CLICKED",
}
],
onSuccessCallback: (data) {
print("Tooltip CTA Clicked, $data");
},
onErrorCallback: (error, stacktrace) {
print("Error: $error");
},
);
if (clickType == "DEEP_LINK") {
_launchUrl(target!);
} else if (clickType == "EXTERNAL_URL") {
_launchUrl(target!);
} else if (clickType == "NEXT_NUDGE") {
print("Next Nudge");
NudgeNudgesUi.currentNudgeIndex++;
if (NudgeNudgesUi.currentNudgeIndex <
rootData.components.length) {
print(
"Next Nudge Index: ${NudgeNudgesUi.currentNudgeIndex}, type : ${rootData.components[NudgeNudgesUi.currentNudgeIndex].componentProps.name}");
if (rootData
.components[
NudgeNudgesUi.currentNudgeIndex]
.componentProps
.type ==
"spotlight") {
print("Spotlight");
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
nudgeSpotlight(context, rootData, eventName);
} else if (rootData
.components[
NudgeNudgesUi.currentNudgeIndex]
.componentProps
.type ==
"coachmark") {
print("Coachmark");
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
nudgeCoachMark(context, rootData, eventName);
} else if (rootData
.components[
NudgeNudgesUi.currentNudgeIndex]
.componentProps
.type ==
"tooltip") {
print("Tooltip");
overlayForegroundEntry?.remove();
overlayBackgroundEntry?.remove();
nudgeTooltip(context, rootData, eventName);
}
} else {
overlayBackgroundEntry?.remove();
overlayForegroundEntry?.remove();
}
}
},
nudgeProps: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.toJson(),
type: () {
if (rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.componentProps
.orientation ==
"vertical") {
return 20;
} else {
return 21;
}
}(),
json: rootData
.components[NudgeNudgesUi.currentNudgeIndex]
.widgets!,
assetUrl: assetUrl,
assets: Nudge.assets,
),
if (tooltipPosition == "left")
Padding(
padding: const EdgeInsets.only(
top: 0.0,
bottom: 0.0,
right: 10,
),
child: CustomPaint(
size: const Size(10, 20), // Set the size explicitly
painter: TrianglePainter(
color: fillColor,
arrowDirection: ArrowDirection.right,
),
),
),
],
),
);
});
WidgetDetails? targetViewFinal =
NudgeWidgetTracker.findWidgetPositionByLabel(
NudgeNudgesUi.componentName,
scaleWidth,
scaleHeight,
);
if (targetViewFinal != null) {
NudgeProviderState.navigatorKey.currentState?.overlay
?.insert(overlayForegroundEntry!);
} else if (isPositionBased) {
NudgeProviderState.navigatorKey.currentState?.overlay
?.insert(overlayForegroundEntry!);
}
} else {
if (kDebugMode) {
print("Content Key is null");
}
}
});
WidgetDetails? targetViewFinal =
NudgeWidgetTracker.findWidgetPositionByLabel(
NudgeNudgesUi.componentName,
scaleWidth,
scaleHeight,
);
if (targetViewFinal != null) {
if (targetViewFinal.x == targetView?.x &&
targetViewFinal.y == targetView?.y) {
overlayForegroundEntry?.remove();
NudgeProviderState.navigatorKey.currentState!.overlay
?.insert(overlayForegroundEntry!);
}
} else if (isPositionBased) {
overlayForegroundEntry?.remove();
NudgeProviderState.navigatorKey.currentState?.overlay
?.insert(overlayForegroundEntry!);
}
});
}