Skip to content

[FEAT] Image component updates#6

Merged
mack-at-pieces merged 4 commits into
mainfrom
feat_image_component_updates
Feb 5, 2026
Merged

[FEAT] Image component updates#6
mack-at-pieces merged 4 commits into
mainfrom
feat_image_component_updates

Conversation

@rutvik-at-pieces

Copy link
Copy Markdown

[FEAT] Image component updates

Copilot AI review requested due to automatic review settings February 3, 2026 09:40
@rutvik-at-pieces rutvik-at-pieces self-assigned this Feb 3, 2026
child: SelectableBox(
selectionColor: selectionColor,
selection: selection,
enableIgnorePointer: selection != null,

This comment was marked as outdated.

Copilot AI 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.

Pull request overview

This PR adds support for alternative text (altText) to image components and makes several structural changes to the ImageComponent widget tree. The changes include adding an altText property throughout the image component hierarchy, refactoring the imageBuilder function signature to use named parameters and include altText, reorganizing imports to use absolute package imports, and restructuring the ImageComponent widget tree.

Changes:

  • Added altText property to ImageNode, ImageComponentViewModel, ImageComponentBuilder, and ImageComponent
  • Changed imageBuilder function signature from positional to named parameters and added altText support
  • Reorganized imports to use absolute package:super_editor/src/... imports instead of relative imports
  • Restructured ImageComponent widget tree, removing outer MouseRegion and IgnorePointer, and reordering BoxComponent and SelectableBox
  • Added enableIgnorePointer parameter to SelectableBox to control pointer event handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
super_editor/lib/src/default_editor/image.dart Added altText property throughout image component hierarchy, changed imageBuilder signature to named parameters, restructured widget tree, and reorganized imports
super_editor/lib/src/default_editor/box_component.dart Added enableIgnorePointer parameter to SelectableBox for conditional pointer event handling and reorganized imports

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread super_editor/lib/src/default_editor/image.dart Outdated
this.imageBuilder,
});

final Widget Function(BuildContext context, {required String imageUrl, String altText})? imageBuilder;

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The imageBuilder signature has been changed from (BuildContext context, String imageUrl) to (BuildContext context, {required String imageUrl, String altText}). This is a breaking change that breaks existing test code:

  • super_editor/test/super_editor/supereditor_components_test.dart:198
  • super_editor/test/super_editor/supereditor_test_tools.dart:1035

These tests need to be updated to use named parameters. Additionally, consider making the altText parameter required (required String altText) since it's always passed when calling the builder at line 251.

Suggested change
final Widget Function(BuildContext context, {required String imageUrl, String altText})? imageBuilder;
final Widget Function(BuildContext context, {required String imageUrl, required String altText})? imageBuilder;

Copilot uses AI. Check for mistakes.
child: SelectableBox(
selectionColor: selectionColor,
selection: selection,
enableIgnorePointer: selection != null,

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The logic for enableIgnorePointer appears to be inverted. The parameter is set to selection != null, which means IgnorePointer will be enabled (ignoring = true) when there IS a selection. This seems counterintuitive - typically you would want to ignore pointer events when there is NO selection, not when there is one. Consider whether this should be selection == null instead, or if the parameter name should be changed to better reflect the intended behavior.

Suggested change
enableIgnorePointer: selection != null,
enableIgnorePointer: selection == null,

Copilot uses AI. Check for mistakes.
Comment on lines +243 to +249
child: BoxComponent(
key: componentKey,
opacity: opacity,
child: SelectableBox(
selectionColor: selectionColor,
selection: selection,
enableIgnorePointer: selection != null,

Copilot AI Feb 3, 2026

Copy link

Choose a reason for hiding this comment

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

The widget tree structure has been changed, placing BoxComponent (which applies opacity) above SelectableBox. This means that the selection decoration will now be affected by the opacity setting of the image component, whereas in the previous implementation, the selection decoration was not affected by opacity. If this is intentional, it's fine, but if selection decorations should always be visible at full opacity regardless of component opacity, this change will cause a regression.

Suggested change
child: BoxComponent(
key: componentKey,
opacity: opacity,
child: SelectableBox(
selectionColor: selectionColor,
selection: selection,
enableIgnorePointer: selection != null,
child: SelectableBox(
selectionColor: selectionColor,
selection: selection,
enableIgnorePointer: selection != null,
child: BoxComponent(
key: componentKey,
opacity: opacity,

Copilot uses AI. Check for mistakes.
@mack-at-pieces mack-at-pieces merged commit 88ed4f2 into main Feb 5, 2026
2 checks passed
@mack-at-pieces mack-at-pieces deleted the feat_image_component_updates branch February 5, 2026 18:17
///
/// If [imageBuilder] is `null` an [Image] is used.
final Widget Function(BuildContext context, String imageUrl)? imageBuilder;
final Widget Function(BuildContext context, {required String imageUrl, String altText})? imageBuilder;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The imageBuilder signature change to named parameters is a breaking change, as test utilities still use the old positional signature, causing runtime errors in tests.
Severity: HIGH

Suggested Fix

Update the imageBuilder definitions in all affected test files (supereditor_test_tools.dart, supereditor_components_test.dart, test_tools.dart) to use the new signature with named parameters. For example, change (context, imageUrl) => ... to (context, {required String imageUrl, String? altText}) => ....

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: super_editor/lib/src/default_editor/image.dart#L238

Potential issue: The `imageBuilder` function signature was changed from using positional
parameters to named parameters (`Widget Function(BuildContext context, {required String
imageUrl, String altText})`). However, several test utility files, including
`super_editor/test/super_editor/supereditor_test_tools.dart`, still define
`imageBuilder` implementations using the old positional signature, like `(context,
imageUrl) => ...`. This creates a type incompatibility. When the code attempts to invoke
the builder with named parameters, it will cause a runtime error because the provided
function expects positional parameters. This will lead to failures in numerous tests
that rely on these utilities.

tsavo-at-pieces added a commit that referenced this pull request May 9, 2026
…lutter 3.35-3.40 compat)

Upstream commit b422c32 (PR Flutter-Bounty-Hunters#2950, Feb 2026) added:

  @OverRide
  void updateStyle(TextInputStyle style) => client?.updateStyle(style);

to TextInputConnectionDecorator in anticipation of Flutter's
"Deprecate TextInputConnection.setStyle" breaking change
(flutter/flutter#180436), which adds TextInputConnection.updateStyle(
TextInputStyle) and deprecates setStyle(...).

Per docs.flutter.dev/release/breaking-changes/deprecate-text-input-
connection-set-style (last updated 2026-03-03), the change is "Landed
in version: TBD / In stable release: Not yet."

Our pinned Flutter is 3.35.7 (`flutter --version`):
  - flutter-sdk-3.35.5/packages/flutter/lib/src/services/text_input.dart
    declares only `void setStyle({...})`. There is no `class TextInputStyle`
    and no `void updateStyle(...)` on TextInputConnection.
  - TextInputConnectionDecorator implements TextInputConnection, so the
    override fails to compile: "TextInputStyle isn't a type" + "method
    updateStyle isn't defined for the type TextInputConnection".

There is no Dart conditional-imports trick that can selectively
include an interface override based on host SDK version (conditional
imports switch libraries, not class members).

Fix: drop the override and replace it with a comment block that:
  - Explains the upstream origin (PR Flutter-Bounty-Hunters#2950, commits 4703643 / b422c32).
  - Cites the Flutter breaking-change doc.
  - Documents restore criteria (when Flutter ships TextInputStyle in
    stable AND we upgrade past that release).

This is a no-op functionally on stable Flutter: setStyle(...) above
already covers the entire surviving public API; the framework can't
call a method that doesn't exist on the parent class.

Tracked as fork divergence #6 in FORK_CHANGES.md, marked as
TEMPORARY. Will be re-asserted on each upstream sync until either
upstream gates this on a Flutter version constraint or we upgrade
past the TextInputStyle-shipping stable release.

Refs: #13 (parent merge PR)
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.

3 participants