Skip to content

chore: Exports ImageRenderMethodForWeb - #1029

Open
thKali wants to merge 1 commit into
Baseflow:mainfrom
thKali:develop
Open

thKali wants to merge 1 commit into
Baseflow:mainfrom
thKali:develop

Conversation

@thKali

@thKali thKali commented Nov 6, 2025

Copy link
Copy Markdown

Allow external configuration

✨ What kind of change does this PR introduce? (Bug fix, feature, docs update...)

DX improvement

⤵️ What is the current behavior?

when attempting to configure the imageRenderMethodForWeb property of CachedNetworkImageProvider, the required ImageRenderMethodForWeb enum is inaccessible.

🆕 What is the new behavior (if this is a feature change)?

ImageRenderMethodForWeb enum is now publicly exported, allowing consumers to configure the imageRenderMethodForWeb property.

💥 Does this PR introduce a breaking change?

no

🐛 Recommendations for testing

n/a

📝 Links to relevant issues/docs

#1003

🤔 Checklist before submitting

  • All projects build
  • Follows style guide lines (code style guide)
  • Relevant documentation was updated
  • Rebased onto current develop

Allow external configuration
@rickdijk

Copy link
Copy Markdown
Collaborator

This repository now uses main as its only branch, so I have retargeted this PR from develop to main. Nothing about the review changes. If GitHub now shows a conflict, a rebase onto main will clear it, and we will follow up on that separately.

@DexEze

DexEze commented Oct 13, 2026

Copy link
Copy Markdown

Linked issue tracking the production impact (CanvasKit WebGL texture loss and solid black images during route transitions) that this PR resolves: #1061

@rickdijk rickdijk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this. A few things that don't sit on a diff line:

  • cached_network_image/pubspec.yaml needs a version bump (4.0.4 to 4.1.0, since this adds public API) and a matching CHANGELOG.md entry.
  • A small test that uses ImageRenderMethodForWeb through package:cached_network_image/cached_network_image.dart alone would stop this export from quietly regressing.
  • Neither README mentions imageRenderMethodForWeb. Now that users can set it, a short note on the trade-off would help: HtmlImage (the default) keeps browser caching but can't send custom headers, and HttpGet sends headers but loses browser caching. README.md and cached_network_image/README.md are separate files, so both need it.

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
export 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

ErrorListener has the same problem. It's the type of the public errorListener parameter and still isn't exported, so an app that wants to name the type has to depend on cached_network_image_platform_interface directly, which trips depend_on_referenced_packages. Could you export it alongside ImageRenderMethodForWeb?

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
export 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could this go in lib/cached_network_image.dart instead? That file already re-exports CacheManagerLogLevel and DownloadProgress from flutter_cache_manager with show, so all the public re-exports would live in one place:

export 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'
    show ErrorListener, ImageRenderMethodForWeb;

import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
export 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'
show ImageRenderMethodForWeb;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This branch comes from develop, which we no longer maintain, and it predates the move to material_ui: the context above still imports package:flutter/material.dart, while main imports package:material_ui/material_ui.dart. Could you rebase onto main? The "All projects build" check in the description was run against the old base.

import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
export 'package:cached_network_image_platform_interface/cached_network_image_platform_interface.dart'
show ImageRenderMethodForWeb;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor: re-exporting the enum makes it part of this package's public API, so renaming or removing a value in the platform interface later would be a breaking change here as well. Fine to do, just something to keep in mind when the interface changes.

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