Skip to content

feat: add unknown widget fallback mechanism to VirtualWidgetRegistry - #516

Open
RamSuthar-Digia wants to merge 1 commit into
mainfrom
unknownWidgetFallBack
Open

feat: add unknown widget fallback mechanism to VirtualWidgetRegistry#516
RamSuthar-Digia wants to merge 1 commit into
mainfrom
unknownWidgetFallBack

Conversation

@RamSuthar-Digia

Copy link
Copy Markdown
Collaborator

No description provided.

@coderabbitai

coderabbitai Bot commented Mar 6, 2026

Copy link
Copy Markdown

Walkthrough

Two framework files modified to implement a fallback mechanism for unknown widget types. A new UnknownWidgetFallback callback type is introduced in the virtual widget registry, extended to accept and invoke this callback. The DUI factory wires the callback during initialization to render error widgets conditionally.

Changes

Cohort / File(s) Summary
Unknown Widget Fallback Mechanism
lib/src/framework/virtual_widget_registry.dart, lib/src/framework/ui_factory.dart
Introduces UnknownWidgetFallback callback typedef and extends VirtualWidgetRegistry factory and DefaultVirtualWidgetRegistry constructor to accept optional fallback parameter. Updates createWidget to invoke fallback when unknown widget types are encountered. Wires fallback implementation in DUIFactory.initialize to return DefaultErrorWidget wrapped in VirtualBuilderWidget for specific hosts or debug mode; otherwise returns null.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive No description was provided by the author, making it impossible to assess relevance to the changeset. Add a pull request description explaining the purpose, motivation, and behavior of the unknown widget fallback mechanism.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding an unknown widget fallback mechanism to VirtualWidgetRegistry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unknownWidgetFallBack

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/src/framework/ui_factory.dart`:
- Around line 180-194: The unknownWidgetFallback closure is passing the builder
callback after named parameters to VirtualBuilderWidget which expects the
builder as the first positional argument; update the call in the
unknownWidgetFallback (where VirtualBuilderWidget is constructed) to supply the
builder callback (e.g. (_) => DefaultErrorWidget(...)) as the first positional
argument and then pass commonProps, parentProps, parent, refName,
extendHierarchy as named parameters so the argument order matches
VirtualBuilderWidget's constructor.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7965393b-77cd-4c5b-b8d2-500d0ae078ae

📥 Commits

Reviewing files that changed from the base of the PR and between 7c3034c and a411895.

📒 Files selected for processing (2)
  • lib/src/framework/ui_factory.dart
  • lib/src/framework/virtual_widget_registry.dart

Comment on lines +180 to +194
unknownWidgetFallback: (type, data, parent) {
if (DigiaUIManager().host is DashboardHost ||
DigiaUIManager().host is PreviewHost ||
kDebugMode) {
return VirtualBuilderWidget(
commonProps: data.commonProps,
parentProps: data.parentProps,
parent: parent,
refName: data.refName,
extendHierarchy: false,
(_) => DefaultErrorWidget(
refName: data.refName,
errorMessage: 'Unknown widget type: $type',
),
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== VirtualBuilderWidget constructor signature ==="
head -60 lib/src/framework/base/virtual_builder_widget.dart

echo ""
echo "=== Fallback call site in DUIFactory.initialize (lines 176-197) ==="
sed -n '176,197p' lib/src/framework/ui_factory.dart

Repository: Digia-Technology-Private-Limited/digia_ui

Length of output: 2696


Move the builder callback to the first positional argument of VirtualBuilderWidget.

The VirtualBuilderWidget constructor requires builder as the first positional parameter, but the fallback at lines 184–194 passes named arguments before the builder callback. This violates Dart's argument syntax and will not compile.

Suggested fix
         if (DigiaUIManager().host is DashboardHost ||
             DigiaUIManager().host is PreviewHost ||
             kDebugMode) {
           return VirtualBuilderWidget(
+            (_) => DefaultErrorWidget(
+              refName: data.refName,
+              errorMessage: 'Unknown widget type: $type',
+            ),
             commonProps: data.commonProps,
             parentProps: data.parentProps,
             parent: parent,
             refName: data.refName,
             extendHierarchy: false,
           );
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/src/framework/ui_factory.dart` around lines 180 - 194, The
unknownWidgetFallback closure is passing the builder callback after named
parameters to VirtualBuilderWidget which expects the builder as the first
positional argument; update the call in the unknownWidgetFallback (where
VirtualBuilderWidget is constructed) to supply the builder callback (e.g. (_) =>
DefaultErrorWidget(...)) as the first positional argument and then pass
commonProps, parentProps, parent, refName, extendHierarchy as named parameters
so the argument order matches VirtualBuilderWidget's constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant