Skip to content

Conversation

@bybabek
Copy link
Contributor

@bybabek bybabek commented Jan 5, 2026

PR Checklist (Required)

Please ensure your PR meets the following requirements:

  • The commit message follows our guidelines: https://github.com/hm21/pro_image_editor/blob/stable/CONTRIBUTING.md#style-guides
  • I have run dart format . in the terminal and committed any changes.
  • I have run dart analyze . in the terminal and addressed any issues.
  • I have run flutter test in the terminal and addressed any issues.
  • I have pulled from the stable branch before committing.
  • I have updated the CHANGELOG.md file with my changes (For the version, you can use X.X.X, I will later bump it after it's merged).
  • The PR title follows the conventional commit style (e.g., feat(paint-editor): add new triangle shape).
  • If this PR introduces breaking changes, I have verified that there is no way to implement the changes without them.

PR Checklist (Optional)

  • Tests have been added for the changes.
  • Documentation has been added/updated.

PR Type

Please indicate the types of changes this PR introduces by checking the relevant boxes:

  • Bugfix
  • Feature
  • Performance
  • Refactor (no functional or API changes)
  • Code style updates (e.g., formatting, local variables)
  • Documentation updates
  • CI-related changes
  • Other... Please describe:

Current Behavior

Currently, when loading images from network URLs using ProImageEditor.network() or EditorImage(networkUrl: ...), there is no way to pass custom HTTP headers. This limitation prevents users from:

  • Adding authorization tokens for authenticated image requests
  • Passing API keys required by image hosting services
  • Including custom headers needed for specific server configurations

Issue Number: N/A

New Behavior

Users can now provide optional HTTP headers when loading images from network sources:

// Using ProImageEditor.network constructor
ProImageEditor.network(
  'https://example.com/image.jpg',
  networkHeaders: {
    'Authorization': 'Bearer token123',
    'Custom-Header': 'value',
  },
  callbacks: ProImageEditorCallbacks(...),
);

// Using EditorImage directly
EditorImage(
  networkUrl: 'https://example.com/image.jpg',
  networkHeaders: {
    'Authorization': 'Bearer token123',
  },
);

The headers are properly passed through all image loading operations including:

  • Initial image display via NetworkImage
  • Byte conversion via http.get requests
  • Image equality checks and hash calculations

Breaking Changes?

Does this PR introduce a breaking change?

  • Yes
  • No

This is a backwards-compatible addition. The networkHeaders parameter is optional, and existing code will continue to work without any modifications.

Additional Information

Implementation details:

  • Added networkHeaders field to EditorImage class
  • Updated safeImageProvider to pass headers to NetworkImage
  • Updated safeLoadImageBytes to pass headers to fetchImageAsUint8List
  • Added header equality check in operator == for proper comparison
  • Included headers in hashCode calculation
  • Updated copyWith method to support header copying
  • Added documentation to ProImageEditor.network factory constructor
  • Updated fetchImageAsUint8List utility function to accept optional headers

Testing:
This change has been manually tested with authenticated image URLs and works as expected. The existing test suite continues to pass.

bybabek and others added 3 commits January 5, 2026 16:40
… Add optional headers parameter to fetchImageAsUint8List function - Add networkHeaders property to EditorImage class - Pass headers to NetworkImage in toImageProvider method - Pass headers to fetchImageAsUint8List in safeByteArray method - Update copyWith, equality operator and hashCode to include networkHeaders
Copy link
Owner

@hm21 hm21 left a comment

Choose a reason for hiding this comment

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

Thanks a lot for creating that PR, it's definitely very helpful.

LGTM so I'll go ahead and release a new version right away.

@hm21 hm21 merged commit 00e6022 into hm21:stable Jan 6, 2026
1 check passed
@bybabek
Copy link
Contributor Author

bybabek commented Jan 6, 2026

Thanks a lot for creating that PR, it's definitely very helpful.

LGTM so I'll go ahead and release a new version right away.

Thank you! Happy to help 👍

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