Skip to content

Conversation

@lesleysin
Copy link
Member

@lesleysin lesleysin commented Jun 30, 2025

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive set of animation tween description classes and a new enum for tween types, enabling more flexible animation definitions.
    • Added extensive lookup tables for mapping serialized values to Flutter UI enums and types, supporting dynamic UI configuration.
    • Added conditional annotation for Dart VM inlining based on environment configuration.
    • Added a new command event type and support for remote commands in event handling.
  • Breaking Changes

    • Removed generic parameters from several core classes and interfaces, simplifying attribute and controller handling.
    • Refactored attribute parsing and theme application logic, removing external attribute parser dependencies.
    • Eliminated or modified several public interfaces and typedefs related to attribute parsing and registry.
    • Removed animation trigger event support.
    • Raised the minimum required Flutter SDK version to 3.24.3.
  • Bug Fixes

    • Improved event and action JSON deserialization for safer and more consistent field extraction.
  • Chores

    • Updated CI workflows to test only on supported Flutter versions.
    • Updated .gitignore to exclude coverage reports.
  • Tests

    • Adjusted tests to match new attribute creation logic and removed obsolete test classes.

…lt result return logic, and added table mapping for BlendMode and FloatingActionButtonLocation.
…rationStyle, fontWeight, fontStyle and other attributes. Improved logic for returning default values ​​and added corresponding tests.
…and image filters. Updated tests to check new features and JSON processing logic.
… Updated tests to check new features and JSON handling logic.
…map, as well as corresponding lookup tables. Simplified logic for selecting the border type.
@lesleysin lesleysin self-assigned this Jun 30, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 30, 2025

Walkthrough

This update removes the generic attribute parsing and attribute interface system, consolidating attribute handling around the DuitDataSource and a non-generic ViewAttribute. Several files related to attribute parsing, attribute interfaces, and factory registration are deleted or refactored. The registry system is simplified, and the codebase now uses direct data source lookups and new lookup tables for enum and type conversions. Animation API exports are expanded, and a new tween description system is introduced. The minimum Flutter SDK version is raised, and test and CI configurations are updated accordingly.

Changes

File(s) Change Summary
.gitignore Added coverage/ directory to ignored files.
pubspec.yaml Updated minimum Flutter SDK version to >=3.24.3.
.github/workflows/pr.yaml, .github/workflows/post-merge.yaml Removed Flutter 3.22.3 from CI test matrix.
lib/src/action_api/action.dart, lib/src/action_api/action_parser.dart Replaced ServerActionJsonView with DuitDataSource for JSON parsing in actions.
lib/src/action_api/event.dart Made ServerEvent constructor const, refactored event JSON parsing to use DuitDataSource, removed AnimationTriggerEvent, added CommandEvent.
lib/src/action_api/event_parser.dart Removed "animationTrigger" event type, added "command" event type parsing.
lib/src/action_api/event_resolver.dart Replaced AnimationTriggerEvent handling with CommandEvent handling.
lib/src/action_api/index.dart Removed export of server_action_view.dart; added export of command.dart.
lib/src/action_api/server_action_view.dart Deleted: Extension for action JSON view removed.
lib/src/action_api/command.dart New: Added RemoteCommand base class.
lib/src/animation_api/index.dart Removed export of command.dart; added exports of tween_description.dart and tween_type.dart.
lib/src/animation_api/tween_description.dart New: Introduced base and specialized tween description classes for animations.
lib/src/animation_api/tween_type.dart New: Added TweenType enum for animation tween types.
lib/src/driver_api/dependency.dart Removed ActionDependency.fromJson factory constructor.
lib/src/driver_api/script_def.dart Removed ScriptDefinition.fromJson factory constructor.
lib/src/driver_api/ui_controller.dart Made UIElementController non-generic, updated method/property types, removed cast method, changed command types to RemoteCommand.
lib/src/misc/annotations.dart New: Added environment-based preferInline constant for VM pragma.
lib/src/misc/index.dart Exported annotations.dart.
lib/src/registry_api/attributes_factory.dart Deleted: Removed AttributesFactory typedef.
lib/src/registry_api/factory_record.dart Removed attributesFactory from FactoryRecord typedef.
lib/src/registry_api/index.dart Removed export of attributes_factory.dart.
lib/src/registry_api/registry.dart Removed attributesFactory parameter and method from DuitRegistry.
lib/src/ui/theme/theme_override_rule.dart Removed fromString static method from ThemeOverrideRule enum.
lib/src/ui/tree_element.dart Made ElementTreeEntry non-generic, updated property types.
lib/src/view_attributes/attribute_parser.dart Deleted: Removed AttributeParserBase interface.
lib/src/view_attributes/attributes.dart Deleted: Removed DuitAttributes interface.
lib/src/view_attributes/index.dart Removed exports of attribute_parser.dart and attributes.dart; added export of data_source.dart.
lib/src/view_attributes/lookup.dart New: Added comprehensive lookup tables for enum and type conversions.
lib/src/view_attributes/view_attribute.dart Made ViewAttribute non-generic, removed parser logic, added from factory, changed payload to DuitDataSource.
test/misc.dart Removed test attribute parser and attribute classes.
test/theme_test.dart Removed attribute parser setup; updated calls to ViewAttribute.createAttributes (removed generics, added id and tag).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant ViewAttribute
    participant DuitRegistry
    participant DuitDataSource

    Client->>ViewAttribute: from(type, json, id, tag)
    ViewAttribute->>DuitRegistry: theme (for tag/type)
    DuitRegistry-->>ViewAttribute: theme token (optional)
    ViewAttribute->>DuitDataSource: (wraps payload map)
    ViewAttribute-->>Client: ViewAttribute instance (with DuitDataSource payload)
Loading
sequenceDiagram
    participant EventFactory
    participant DuitDataSource

    EventFactory->>DuitDataSource: fromJson(json)
    DuitDataSource-->>EventFactory: getString/getMap/getDuration, etc.
    EventFactory-->>EventFactory: Construct event instance with extracted fields
Loading
sequenceDiagram
    participant ActionFactory
    participant DuitDataSource

    ActionFactory->>DuitDataSource: fromJson(json)
    DuitDataSource-->>ActionFactory: getString/getActionDependencies, etc.
    ActionFactory-->>ActionFactory: Construct action instance with extracted fields
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 17

🔭 Outside diff range comments (3)
lib/src/ui/tree_element.dart (1)

11-12: Update documentation to reflect removed generic parameter.

The documentation still references the removed generic type parameter T. This needs to be updated to reflect the current non-generic implementation.

-/// Type parameter:
-/// - [T]: The type of the data associated with the `UIElementController` and `ViewAttribute`.
test/misc.dart (1)

39-39: Fix typo in class name.

The class name contains a grammatical error.

-final class OverridedTextThemeToken extends ThemeToken {
+final class OverriddenTextThemeToken extends ThemeToken {
lib/src/view_attributes/view_attribute.dart (1)

87-142: Refactor deprecated method to avoid code duplication.

The deprecated createAttributes method contains duplicate theme application logic. Consider refactoring it to delegate to the new from factory method.

@Deprecated("Use .from instead")
static ViewAttribute createAttributes(
  String type,
  Map<String, dynamic>? json,
  String? tag, {
  String? id,
}) {
  assert(json != null);
  assert(id != null);
-
-  final ignoreTheme = json!["ignoreTheme"] ?? false;
-  var value = json;
-
-  if (!ignoreTheme) {
-    final themeKey = json["theme"] as String?;
-    final overrideRule = ThemeOverrideRule.fromString(json["overrideRule"]);
-
-    if (themeKey != null) {
-      ThemeToken token;
-
-      if (tag != null) {
-        token = DuitRegistry.theme.getToken(
-          themeKey,
-          tag,
-        );
-      } else {
-        token = DuitRegistry.theme.getToken(
-          themeKey,
-          type,
-        );
-      }
-
-      if (token is UnknownThemeToken) {
-        return ViewAttribute._(
-          id: id!,
-          payload: Map<String, dynamic>.from(value),
-        );
-      }
-
-      if (overrideRule == ThemeOverrideRule.themeOverlay) {
-        value = {
-          ...token.widgetTheme,
-          ...value,
-        };
-      } else {
-        value.addAll(
-          token.widgetTheme,
-        );
-      }
-    }
-  }
-
-  return ViewAttribute._(
-    id: id!,
-    payload: Map<String, dynamic>.from(value),
-  );
+  return ViewAttribute.from(type, json!, id!, tag: tag);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d703732 and 39c900f.

📒 Files selected for processing (22)
  • .gitignore (1 hunks)
  • lib/src/action_api/event.dart (2 hunks)
  • lib/src/animation_api/index.dart (1 hunks)
  • lib/src/animation_api/tween.dart (1 hunks)
  • lib/src/animation_api/tween_description.dart (1 hunks)
  • lib/src/driver_api/ui_controller.dart (3 hunks)
  • lib/src/misc/annotations.dart (1 hunks)
  • lib/src/misc/index.dart (1 hunks)
  • lib/src/registry_api/attributes_factory.dart (0 hunks)
  • lib/src/registry_api/factory_record.dart (0 hunks)
  • lib/src/registry_api/index.dart (0 hunks)
  • lib/src/registry_api/registry.dart (0 hunks)
  • lib/src/ui/theme/theme_override_rule.dart (0 hunks)
  • lib/src/ui/tree_element.dart (1 hunks)
  • lib/src/view_attributes/attribute_parser.dart (0 hunks)
  • lib/src/view_attributes/attributes.dart (0 hunks)
  • lib/src/view_attributes/index.dart (1 hunks)
  • lib/src/view_attributes/lookup.dart (1 hunks)
  • lib/src/view_attributes/view_attribute.dart (3 hunks)
  • pubspec.yaml (1 hunks)
  • test/misc.dart (1 hunks)
  • test/theme_test.dart (6 hunks)
💤 Files with no reviewable changes (7)
  • lib/src/registry_api/index.dart
  • lib/src/registry_api/factory_record.dart
  • lib/src/ui/theme/theme_override_rule.dart
  • lib/src/view_attributes/attributes.dart
  • lib/src/registry_api/attributes_factory.dart
  • lib/src/view_attributes/attribute_parser.dart
  • lib/src/registry_api/registry.dart
🔇 Additional comments (11)
lib/src/animation_api/index.dart (1)

6-7: LGTM: Clean API expansion.

The new exports properly expand the animation API with tween functionality while maintaining consistency with the existing export pattern.

lib/src/view_attributes/index.dart (1)

2-2: LGTM: API refactoring in progress.

The addition of the data_source.dart export aligns with the attribute handling refactoring mentioned in the AI summary. The export follows the existing pattern.

test/theme_test.dart (3)

68-78: API change looks consistent.

The test method call has been properly updated to match the new ViewAttribute API signature.


89-99: API change looks consistent.

The test method call has been properly updated to match the new ViewAttribute API signature.


50-58: Verified: All ViewAttribute.createAttributes calls use the new signature

A project-wide search confirmed every invocation—including the three in test/theme_test.dart—now includes the id parameter and omits the generic type. No legacy signatures remain.

lib/src/ui/tree_element.dart (2)

24-24: LGTM: Generic parameter removal is clean.

The removal of the generic type parameter aligns with the broader type system simplification mentioned in the AI summary.


29-30: LGTM: Property types updated consistently.

The property types have been properly updated to match the non-generic class definition.

lib/src/action_api/event.dart (1)

18-18: Good optimization with const constructor.

Making the ServerEvent constructor const enables compile-time optimizations.

lib/src/animation_api/tween_description.dart (1)

79-83: Good validation for group tweens.

The assertions properly validate that group tweens have the required structure.

lib/src/view_attributes/view_attribute.dart (1)

24-69: Well-structured theme handling implementation.

The new from factory constructor properly handles theme token application with clear logic for theme overlays and fallbacks.

lib/src/view_attributes/lookup.dart (1)

1-2: Verify that data_source.dart re-exports Flutter types

This part file relies on many Flutter classes (TextAlign, Curves, …) but has no imports itself.
Please make sure data_source.dart, the library file, includes

import 'package:flutter/material.dart';
import 'dart:ui';

or equivalent; otherwise the build will fail.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39c900f and e7bd80c.

📒 Files selected for processing (2)
  • .github/workflows/post-merge.yaml (1 hunks)
  • .github/workflows/pr.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.37.1)
.github/workflows/post-merge.yaml

[error] 14-14: too many spaces inside brackets

(brackets)


[error] 14-14: too many spaces inside brackets

(brackets)

.github/workflows/pr.yaml

[error] 11-11: too many spaces inside brackets

(brackets)


[error] 11-11: too many spaces inside brackets

(brackets)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🔭 Outside diff range comments (2)
lib/src/view_attributes/view_attribute.dart (1)

87-143: Remove deprecated method to eliminate code duplication.

The deprecated createAttributes method contains logic that duplicates the new from factory constructor. Since it's already marked as deprecated, consider removing it entirely to reduce maintenance burden and avoid inconsistencies.

If immediate removal isn't feasible, simplify it to delegate to the new method:

-  @Deprecated("Use .from instead")
-  static ViewAttribute createAttributes(
-    String type,
-    Map<String, dynamic>? json,
-    String? tag, {
-    String? id,
-  }) {
-    assert(json != null);
-    assert(id != null);
-
-    final ignoreTheme = json!["ignoreTheme"] ?? false;
-    var value = json;
-
-    if (!ignoreTheme) {
-      final themeKey = json["theme"] as String?;
-      final overrideRule = ThemeOverrideRule.fromString(json["overrideRule"]);
-
-      if (themeKey != null) {
-        ThemeToken token;
-
-        if (tag != null) {
-          token = DuitRegistry.theme.getToken(
-            themeKey,
-            tag,
-          );
-        } else {
-          token = DuitRegistry.theme.getToken(
-            themeKey,
-            type,
-          );
-        }
-
-        if (token is UnknownThemeToken) {
-          return ViewAttribute._(
-            id: id!,
-            payload: Map<String, dynamic>.from(value),
-          );
-        }
-
-        if (overrideRule == ThemeOverrideRule.themeOverlay) {
-          value = {
-            ...token.widgetTheme,
-            ...value,
-          };
-        } else {
-          value.addAll(
-            token.widgetTheme,
-          );
-        }
-      }
-    }
-
-    return ViewAttribute._(
-      id: id!,
-      payload: Map<String, dynamic>.from(value),
-    );
-  }
+  @Deprecated("Use .from instead")
+  static ViewAttribute createAttributes(
+    String type,
+    Map<String, dynamic>? json,
+    String? tag, {
+    String? id,
+  }) {
+    assert(json != null);
+    assert(id != null);
+    return ViewAttribute.from(type, json!, id!, tag: tag);
+  }
lib/src/action_api/action_parser.dart (1)

5-6: Update documentation to reflect DuitDataSource usage.

The documentation still references ServerActionJsonView which has been replaced with DuitDataSource.

-/// It uses a [ServerActionJsonView] to parse the JSON map into a concrete action
-/// object based on the [ExecutionType] of the action.
+/// It uses a [DuitDataSource] to parse the JSON map into a concrete action
+/// object based on the [ExecutionType] of the action.
♻️ Duplicate comments (2)
lib/src/animation_api/tween_description.dart (1)

1-437: Past review comments appear outdated.

The previous review comments mention a typo ("forvard" → "forward") and a large fromJson method that don't exist in the current implementation. These comments seem to reference an earlier version of the file.

lib/src/view_attributes/view_attribute.dart (1)

75-80: Remove commented-out code.

The cast<R>() method is commented out. Remove it entirely if this functionality is no longer needed.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7bd80c and b71f6c0.

📒 Files selected for processing (11)
  • lib/src/action_api/action.dart (2 hunks)
  • lib/src/action_api/action_parser.dart (1 hunks)
  • lib/src/action_api/event.dart (8 hunks)
  • lib/src/action_api/index.dart (0 hunks)
  • lib/src/action_api/server_action_view.dart (0 hunks)
  • lib/src/animation_api/index.dart (1 hunks)
  • lib/src/animation_api/tween_description.dart (1 hunks)
  • lib/src/animation_api/tween_type.dart (1 hunks)
  • lib/src/driver_api/dependency.dart (0 hunks)
  • lib/src/driver_api/script_def.dart (0 hunks)
  • lib/src/view_attributes/view_attribute.dart (3 hunks)
💤 Files with no reviewable changes (4)
  • lib/src/action_api/index.dart
  • lib/src/driver_api/dependency.dart
  • lib/src/driver_api/script_def.dart
  • lib/src/action_api/server_action_view.dart
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test (3.27.3)
🔇 Additional comments (7)
lib/src/animation_api/tween_type.dart (1)

1-12: Well-structured enum for tween type categorization.

The TweenType enum provides a clear categorization of different animation types. The naming convention is consistent and the values align well with Flutter's built-in tween types.

lib/src/animation_api/index.dart (1)

6-7: Appropriate exports for new animation API components.

The new export statements properly expose the tween description system and tween type enum, making them available as part of the public animation API.

lib/src/animation_api/tween_description.dart (2)

1-67: Excellent base class design with comprehensive documentation.

The DuitTweenDescription<T> base class provides a solid foundation for the animation system. The generic type parameter, thorough documentation, and practical examples make this highly usable and maintainable.


151-437: Consistent and well-documented specialized tween classes.

All the specialized tween description classes follow a consistent pattern and provide excellent documentation with practical examples. The use of final class appropriately prevents further inheritance where not needed.

lib/src/action_api/action.dart (2)

105-113: LGTM!

The migration to DuitDataSource for JSON parsing is correctly implemented.


133-140: LGTM!

The migration to DuitDataSource is consistent with the rest of the codebase.

lib/src/action_api/event.dart (1)

48-51: LGTM!

Good defensive programming with the null-safe default for missing updates.

lesleysin and others added 4 commits June 30, 2025 21:20
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@lesleysin
Copy link
Member Author

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ BugBot reviewed your changes and found no bugs!


BugBot free trial expires on July 22, 2025
You have used $0.00 of your $50.00 spend limit so far. Manage your spend limit in the Cursor dashboard.

Was this report helpful? Give feedback by reacting with 👍 or 👎

@lesleysin
Copy link
Member Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Jun 30, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
lib/src/animation_api/tween_description.dart (1)

125-130: Add documentation for placeholder values in TweenDescriptionGroup constructor.

The constructor uses placeholder values ("" for animatedPropKey, null for begin/end, and Curves.linear for curve) since groups don't animate specific properties directly. This design choice should be documented to clarify the intent for future maintainers.

        ) : super(
+           // Placeholder values since groups don't animate specific properties
            animatedPropKey: "",
            end: null,
            begin: null,
            curve: Curves.linear,
          );
lib/src/view_attributes/lookup.dart (1)

1143-1150: String keys use PascalCase while other tables use camelCase.

The shape-border lookup table uses "RoundedRectangleBorder" etc., which is inconsistent with the camelCase pattern used throughout the rest of the file. Either update the keys to camelCase to maintain consistency with other lookup tables, or document this intentional deviation clearly.

const _shapeBorderTypeStringLookupTable =
    <String, ShapeBorder Function(Map<String, dynamic> value)>{
-  "RoundedRectangleBorder": DuitDataSource._roundedRectangleBorderFromMap,
-  "CircleBorder": DuitDataSource._circleBorderFromMap,
-  "StadiumBorder": DuitDataSource._stadiumBorderFromMap,
-  "BeveledRectangleBorder": DuitDataSource._beveledRectangleBorderFromMap,
-  "ContinuousRectangleBorder": DuitDataSource._continuousRectangleBorderFromMap,
+  "roundedRectangleBorder": DuitDataSource._roundedRectangleBorderFromMap,
+  "circleBorder": DuitDataSource._circleBorderFromMap,
+  "stadiumBorder": DuitDataSource._stadiumBorderFromMap,
+  "beveledRectangleBorder": DuitDataSource._beveledRectangleBorderFromMap,
+  "continuousRectangleBorder": DuitDataSource._continuousRectangleBorderFromMap,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 76e0bba and e4ae9cf.

📒 Files selected for processing (3)
  • lib/src/animation_api/tween_description.dart (1 hunks)
  • lib/src/view_attributes/lookup.dart (1 hunks)
  • test/misc.dart (0 hunks)
💤 Files with no reviewable changes (1)
  • test/misc.dart
🔇 Additional comments (1)
lib/src/view_attributes/lookup.dart (1)

1-1151: Excellent centralized approach to enum mappings.

This file provides a comprehensive and well-organized centralized location for Flutter enum mappings. The consistent pattern of providing both integer and string lookup tables offers good flexibility for different data sources, and the extensive documentation makes the supported values clear for each enum type.

Comment on lines +151 to +437
final class TweenDescription extends DuitTweenDescription<double> {
/// Creates a new tween description for double-based animations.
TweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for a [ColorTween] animation that animates between Color values.
///
/// This class is used for animating color properties such as background color,
/// text color, border color, and other color-based values.
///
/// Example usage:
/// ```dart
/// final colorTween = ColorTweenDescription(
/// animatedPropKey: 'backgroundColor',
/// duration: Duration(milliseconds: 300),
/// begin: Colors.red,
/// end: Colors.blue,
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onHover,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: true,
/// );
/// ```
final class ColorTweenDescription extends DuitTweenDescription<Color> {
/// Creates a new color tween description.
ColorTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for a [TextStyleTween] animation that animates between TextStyle values.
///
/// This class is used for animating text style properties such as font size,
/// font weight, color, and other text-related styling.
///
/// Example usage:
/// ```dart
/// final textStyleTween = TextStyleTweenDescription(
/// animatedPropKey: 'textStyle',
/// duration: Duration(milliseconds: 400),
/// begin: TextStyle(fontSize: 14, color: Colors.black),
/// end: TextStyle(fontSize: 18, color: Colors.blue, fontWeight: FontWeight.bold),
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onFocus,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: false,
/// );
/// ```
final class TextStyleTweenDescription extends DuitTweenDescription<TextStyle> {
/// Creates a new text style tween description.
TextStyleTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for a [DecorationTween] animation that animates between Decoration values.
///
/// This class is used for animating decoration properties such as borders,
/// backgrounds, shadows, and other decorative elements.
///
/// Example usage:
/// ```dart
/// final decorationTween = DecorationTweenDescription(
/// animatedPropKey: 'decoration',
/// duration: Duration(milliseconds: 600),
/// begin: BoxDecoration(
/// color: Colors.white,
/// borderRadius: BorderRadius.circular(8),
/// ),
/// end: BoxDecoration(
/// color: Colors.blue,
/// borderRadius: BorderRadius.circular(20),
/// boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 10)],
/// ),
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onTap,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: true,
/// );
/// ```
final class DecorationTweenDescription
extends DuitTweenDescription<Decoration> {
/// Creates a new decoration tween description.
DecorationTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for an [AlignmentTween] animation that animates between AlignmentGeometry values.
///
/// This class is used for animating alignment properties such as positioning
/// of widgets within their containers.
///
/// Example usage:
/// ```dart
/// final alignmentTween = AlignmentTweenDescription(
/// animatedPropKey: 'alignment',
/// duration: Duration(milliseconds: 500),
/// begin: Alignment.topLeft,
/// end: Alignment.bottomRight,
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onTap,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: true,
/// );
/// ```
final class AlignmentTweenDescription
extends DuitTweenDescription<AlignmentGeometry> {
/// Creates a new alignment tween description.
AlignmentTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for an [EdgeInsetsTween] animation that animates between EdgeInsetsGeometry values.
///
/// This class is used for animating padding and margin properties.
///
/// Example usage:
/// ```dart
/// final edgeInsetsTween = EdgeInsetsTweenDescription(
/// animatedPropKey: 'padding',
/// duration: Duration(milliseconds: 300),
/// begin: EdgeInsets.all(8),
/// end: EdgeInsets.all(16),
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onHover,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: true,
/// );
/// ```
final class EdgeInsetsTweenDescription
extends DuitTweenDescription<EdgeInsetsGeometry> {
/// Creates a new edge insets tween description.
EdgeInsetsTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for a [BoxConstraintsTween] animation that animates between BoxConstraints values.
///
/// This class is used for animating constraint properties such as minimum and maximum
/// width and height of widgets.
///
/// Example usage:
/// ```dart
/// final boxConstraintsTween = BoxConstraintsTweenDescription(
/// animatedPropKey: 'constraints',
/// duration: Duration(milliseconds: 400),
/// begin: BoxConstraints(minWidth: 100, minHeight: 50),
/// end: BoxConstraints(minWidth: 200, minHeight: 100),
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onTap,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: false,
/// );
/// ```
final class BoxConstraintsTweenDescription
extends DuitTweenDescription<BoxConstraints> {
/// Creates a new box constraints tween description.
BoxConstraintsTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for a [SizeTween] animation that animates between Size values.
///
/// This class is used for animating size properties of widgets.
///
/// Example usage:
/// ```dart
/// final sizeTween = SizeTweenDescription(
/// animatedPropKey: 'size',
/// duration: Duration(milliseconds: 500),
/// begin: Size(100, 50),
/// end: Size(200, 100),
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onTap,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: true,
/// );
/// ```
final class SizeTweenDescription extends DuitTweenDescription<Size> {
/// Creates a new size tween description.
SizeTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}

/// Description for a [BorderTween] animation that animates between Border values.
///
/// This class is used for animating border properties such as border width,
/// border color, and border style.
///
/// Example usage:
/// ```dart
/// final borderTween = BorderTweenDescription(
/// animatedPropKey: 'border',
/// duration: Duration(milliseconds: 300),
/// begin: Border.all(color: Colors.grey, width: 1),
/// end: Border.all(color: Colors.blue, width: 3),
/// curve: Curves.easeInOut,
/// trigger: AnimationTrigger.onFocus,
/// method: AnimationMethod.forward,
/// reverseOnRepeat: false,
/// );
/// ```
final class BorderTweenDescription extends DuitTweenDescription<Border> {
/// Creates a new border tween description.
BorderTweenDescription({
required super.animatedPropKey,
required super.duration,
required super.begin,
required super.end,
required super.curve,
required super.trigger,
required super.method,
required super.reverseOnRepeat,
super.interval,
});
}
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Consider reducing code duplication in tween description classes.

The specific tween description classes (TweenDescription, ColorTweenDescription, etc.) follow an identical pattern with only the generic type parameter changing. While the current explicit approach provides excellent type safety and developer experience, consider if a factory method or builder pattern could reduce the repetitive boilerplate code.

Example approach:

// Factory method approach
static TweenDescription<T> create<T>({
  required String animatedPropKey,
  required Duration duration,
  required T begin,
  required T end,
  // ... other parameters
}) => TweenDescription<T>(...);

However, keep the current approach if explicit typing and clear class names are prioritized for API clarity.

🤖 Prompt for AI Agents
In lib/src/animation_api/tween_description.dart from lines 151 to 437, the
multiple tween description classes have repetitive constructors differing only
by their generic type. To reduce duplication, consider implementing a generic
factory method or builder pattern that takes the generic type as a parameter and
returns the appropriate tween description instance. This will centralize the
construction logic and eliminate boilerplate while preserving type safety.
However, if explicit class names and clear API readability are more important,
you may keep the current explicit class definitions.

/// Lookup table for [FloatingActionButtonLocation] values by [int] type key.
///
/// Maps integer identifiers to [FloatingActionButtonLocation] values for FAB location.
/// Supported values: 0-17 (см. порядок FloatingActionButtonLocation).
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Replace non-English text in documentation.

The comment contains Russian text that should be translated to English for consistency and accessibility.

-/// Supported values: 0-17 (см. порядок FloatingActionButtonLocation).
+/// Supported values: 0-17 (see FloatingActionButtonLocation enum order).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Supported values: 0-17 (см. порядок FloatingActionButtonLocation).
/// Supported values: 0-17 (see FloatingActionButtonLocation enum order).
🤖 Prompt for AI Agents
In lib/src/view_attributes/lookup.dart at line 927, the comment contains Russian
text "см. порядок FloatingActionButtonLocation" which should be translated to
English. Replace the Russian phrase with its English equivalent, such as "see
the order of FloatingActionButtonLocation," to maintain consistency and
accessibility in the documentation.

/// Lookup table for [BlendMode] values by [int] type key.
///
/// Maps integer identifiers to [BlendMode] enum values for blend mode.
/// Supported values: 0-28 (см. порядок BlendMode).
Copy link

Choose a reason for hiding this comment

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

🧹 Nitpick (assertive)

Replace non-English text in documentation.

The comment contains Russian text that should be translated to English for consistency and accessibility.

-/// Supported values: 0-28 (см. порядок BlendMode).
+/// Supported values: 0-28 (see BlendMode enum order).
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/// Supported values: 0-28 (см. порядок BlendMode).
/// Supported values: 0-28 (see BlendMode enum order).
🤖 Prompt for AI Agents
In lib/src/view_attributes/lookup.dart at line 696, replace the Russian text
"см. порядок BlendMode" in the comment with its English equivalent, such as "see
the order of BlendMode," to ensure the documentation is fully in English and
accessible to all developers.

…nimation_api. Updated data references in DuitDataSource class to use new "stretchModes" key. Fixes to tests to match changes in step data.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
lib/src/driver_api/ui_controller.dart (2)

15-15: Breaking change: ViewAttribute no longer generic.

The change from ViewAttribute<T> to non-generic ViewAttribute is consistent with the removal of generic type parameters across the codebase. This simplification aligns with the introduction of DuitDataSource for attribute handling.


71-71: Breaking change: updateState parameter type simplified.

The change from ViewAttribute<T> to Map<String, dynamic> simplifies the state update mechanism and is consistent with the removal of generic type parameters. This change makes the API more straightforward to use.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4ae9cf and 0e092a1.

📒 Files selected for processing (4)
  • lib/src/action_api/index.dart (1 hunks)
  • lib/src/animation_api/command.dart (0 hunks)
  • lib/src/animation_api/index.dart (1 hunks)
  • lib/src/driver_api/ui_controller.dart (4 hunks)
💤 Files with no reviewable changes (1)
  • lib/src/animation_api/command.dart
🔇 Additional comments (3)
lib/src/animation_api/index.dart (1)

5-6: Approve export changes

  • Verified existence of new exports:
    • lib/src/animation_api/tween_description.dart
    • lib/src/animation_api/tween_type.dart
  • These exports align with the architectural refactor: animation API now focuses on tween descriptions, while command functionality resides in the action API.

LGTM.

lib/src/driver_api/ui_controller.dart (2)

90-106: Command handling methods updated consistently.

The updates to listenCommand and emitCommand methods to handle RemoteCommand instead of AnimationCommand are implemented consistently:

  • Method signatures correctly use RemoteCommand
  • Documentation comments updated to reflect the new command type
  • The functionality remains the same with the new command type

49-49: RemoteCommand import verified via public API barrel

Importing package:duit_kernel/duit_kernel.dart brings in RemoteCommand (re-exported from action_api/index.dart), so no additional imports are needed.

export 'server_action_view.dart';
export 'event_parser.dart';
export 'action_parser.dart';
export 'command.dart';
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the new export and ensure breaking changes are handled properly.

The addition of command.dart export aligns with the architectural shift mentioned in the PR summary. However, since this is a breaking change that replaces the previous server_action_view.dart export, please ensure:

  1. The command.dart file exists and contains the expected RemoteCommand class
  2. All consumers of the previous ServerActionJsonView extension have been updated to use the new command system
  3. Documentation or migration guides are provided for the breaking changes

🏁 Script executed:

#!/bin/bash
# Verify the command.dart file exists and contains expected exports
if [ -f "lib/src/action_api/command.dart" ]; then
  echo "✓ command.dart file exists"
  echo "--- Content of command.dart ---"
  cat lib/src/action_api/command.dart
else
  echo "✗ command.dart file does not exist"
fi

# Search for any remaining references to ServerActionJsonView
echo "--- Searching for ServerActionJsonView references ---"
rg "ServerActionJsonView" --type dart

# Search for usages of the old server_action_view import
echo "--- Searching for server_action_view import references ---"
rg "server_action_view" --type dart

Length of output: 1073


Remove remaining ServerActionJsonView dependency in the parser

The new command.dart export is correct and the file contains the RemoteCommand definition. However, there is still a reference to the old ServerActionJsonView in the codebase:

• lib/src/action_api/action_parser.dart
• Line containing "ServerActionJsonView" – update this to use the new command-based parsing approach (e.g. map JSON to RemoteCommand instances).

Please refactor the parser to eliminate the old JSON-view extension and ensure all consumers are updated to the new command system. Also verify that any migration docs or examples are updated to guide users through this breaking change.

🤖 Prompt for AI Agents
In lib/src/action_api/index.dart at line 8, you have correctly exported
command.dart which contains RemoteCommand, but the old ServerActionJsonView is
still referenced in lib/src/action_api/action_parser.dart. Locate the line
referencing ServerActionJsonView in action_parser.dart and refactor it to parse
JSON directly into RemoteCommand instances instead. Remove all dependencies on
ServerActionJsonView and update any related migration documentation or examples
to reflect this change to the new command-based parsing system.

/// This class serves as the base class for all ViewController objects in your application.
/// It provides common properties and methods that can be used by subclasses.
abstract interface class UIElementController<T> {
abstract interface class UIElementController {
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Breaking change: Generic type parameter removed.

The removal of the generic type parameter <T> from UIElementController is a breaking change that simplifies the API. This change is consistent with the broader refactor to remove generic constraints from the attribute system.

Ensure this breaking change is documented in your CHANGELOG.md and migration guide.


🏁 Script executed:

#!/bin/bash
# Check for documentation of breaking changes
fd -t f "CHANGELOG.md" .
fd -t f "MIGRATION.md" .
rg -i "breaking" CHANGELOG.md || echo "No breaking changes documented in CHANGELOG.md"

Length of output: 197


Document Breaking Changes for UIController API

The removal of generics from UIElementController (and related types) is intentional but currently undocumented.

Tasks:

  • Update CHANGELOG.md:
    • Under “Unreleased” (or next version), add a Breaking Changes section listing:
      • UIElementController<T>UIElementController (no generics)
      • ViewAttribute<T>ViewAttribute (no generics)
      • StreamController<AnimationCommand>StreamController<RemoteCommand>
      • updateState(ViewAttribute<T>)updateState(Map<String, dynamic>)
      • Methods updated to handle RemoteCommand instead of AnimationCommand
  • Add or update MIGRATION.md (or a migration guide) with steps for clients to adapt to these API changes.
🤖 Prompt for AI Agents
In lib/src/driver_api/ui_controller.dart at line 10, the removal of generics
from UIElementController and related types is a breaking change that is not yet
documented. Update the CHANGELOG.md file under the “Unreleased” or next version
section by adding a Breaking Changes subsection that lists all the API changes
including the removal of generics from UIElementController and ViewAttribute,
the change from StreamController<AnimationCommand> to
StreamController<RemoteCommand>, the update of updateState parameter from
ViewAttribute<T> to Map<String, dynamic>, and method updates to handle
RemoteCommand instead of AnimationCommand. Additionally, create or update
MIGRATION.md or a migration guide with clear instructions for clients on how to
adapt their code to these API changes.

@lesleysin lesleysin merged commit 0d73f99 into v4 Jul 3, 2025
3 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Aug 3, 2025
lesleysin added a commit that referenced this pull request Nov 5, 2025
* breaking: DuitDataSource (#32)

* experiment - removing attribute support

* wip

* wip

* wip

* refacror ViewAttributes class

* Added  tests

* wip

* Added early exit from methods

* Added new functions for handling JSON parsing results, improved default result return logic, and added table mapping for BlendMode and FloatingActionButtonLocation.

* docs

* add tests

* Added tests

* Removed static mapping tables for Clip, TextAlign, TextOverflow and TextWidthBasis in the DuitDataSource class.

* Added new methods for JSON processing, including support for textDecorationStyle, fontWeight, fontStyle and other attributes. Improved logic for returning default values ​​and added corresponding tests.

* Added tests

* Removed unused methods and added new functions to handle theme rules and image filters. Updated tests to check new features and JSON processing logic.

* Upd .gitignore

* wip

* Upd tests, added Tween parser

* Removed ventilation methods, added new functions for widget handling. Updated tests to check new features and JSON handling logic.

* Refactored functions for creating InputBorder and ShapeBorder from a map, as well as corresponding lookup tables. Simplified logic for selecting the border type.

* Added docs

* upd actions config

* wip

* wip

* Update test/theme_test.dart

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* clean dead code

* fix

* Update lib/src/view_attributes/lookup.dart

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Added export of Command.dart file to action_api and removed it from animation_api. Updated data references in DuitDataSource class to use new "stretchModes" key. Fixes to tests to match changes in step data.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Remote commands API update (#33)

* breaking: Themes refactoring (#34)

* Registry API update: Added new RefWithTarget class, changed component initialization and registration functions, removed unused files, and improved export structure. Updated tests and removed deprecated topic tokens.

* upd workflow

* breaking: Reworking the widget model API and simplifying registration of custom widgets (#35)

* Removed unused factory_record.dart file and updated component registration logic in DuitRegistry class, removed references to model factories. Updated factory getter methods to match new changes.

* Small fix for tweens parser

* rm unused API part

* Update lib/src/registry_api/registry.dart

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* review fixes

* fix

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Improve lootup tables for enums (#36)

* Flutter types json encoding (#37)

* Added encoding functions for: Duration, Size, EdgeInsets, TextStyle, Color, LinearGradient, BoxShadow, Offset, BoxDecoration, BorderRadius, Border, BorderSide, InputBorder, InputDecoration, VisualDensity, ScrollPhysics, ShapeBorder

* wip

* Added tests

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix tests

* Added docs

* dart format

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* feat: action debounce and throttle configuration (#38)

* Added execution options for actions: added ExecutionOptions class with throttle and debounce modifiers, updated ServerAction classes and their descendants to support the new options. Updated parsing methods and added corresponding lookup tables for execution modifiers.

* - Added test
- Refactor DuitDataSource methods with one-line return and fail-fast approach at lookup tables work

* fix Color parsers behavior

* refactoring: improved color handling in _colorFromList function

Changed the typification function of the _colorFromList parameter from List<num> to List, added preprocessing of color data to ensure correct conversion. Updated the corresponding calls in the JSON parsing and processing methods in the DuitDataSource class.

* feat: Fragments registration in DuitRegistry (#39)

Added a new static method registerFragment for registering fragments by key and a method getFragment for receiving a fragment by key with logging in case of absence. Also added an internal registry of fragments _fragmentRegistry.

* Component system refactor (#40)

* Components refactoring via JSON patching instead of Map mutation

* Added tests for json patching and components patches generation

* Review fixes

* Upd lookup table for Curves

* Remover legacy API references

* feat: DuitDataSource methods extension (#41)

* Extend parser for BorderRadius type, added Radius type parsing, upd tests

* fix tests

* Added new Size parsing behavior

* wip

* feat: Custom json reviver (#42)

* Refactor env variables, refactor analysis issues in test files, added FlutterPropertyKeys class

* wip

* wip

* wip

* Fixed analysis issues

* wip

* Fixed getActionDependencies and childObjects methods

* Upd env variables keys

* Code review fixes

* Fix test

* Upd post-merge workflow
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.

2 participants