Skip to content

Flutter web cannot render high resolution images which are resolution aware #109109

Closed
@kenNg1

Description

@kenNg1

Flutter web cannot render high resolution images which are resolution aware. I am using Flutter to build web/mobile apps in one codebase for large clients at our consultancy so it's important that this issue gets fixed so that we can build a high-quality website.

Linked issues and other people facing issues:
#41328 - root cause identified
flutter/engine#17209 - hasn't fixed the issue
https://stackoverflow.com/questions/67716900/flutter-web-pictures-get-pixelated - stack overflow others facing issue (viewed 700+ times)

Root cause:
devicePixelRatio in web is always 1 which means only the lowest resolution image will be rendered.

My app and code:

image

Note: you need to right click the above image and open in new tab to see pixelation issue (as the image is very small on Github). If i hardcode the path to a 2x or 3x image, the image looks crisp so it's definitely a problem.

image

  assets:
    - assets/images/
    - assets/images/2.0x/
    - assets/images/3.0x/
Widget build(BuildContext context) {
    final MediaQueryData queryData = MediaQuery.of(context);
    double devicePixelRatio = queryData.devicePixelRatio;
    print(devicePixelRatio);  // Console prints devicePixelRatio on Web as 1

    return ...
                    Image(
                      width: 412.w,
                      fit: BoxFit.fitWidth,
                      image: const AssetImage(
                        "assets/images/splash-doctors.png",
                      ),
                    ),
                ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: imagesLoading, displaying, rendering imagesc: regressionIt was better in the past than it is nowfound in release: 3.0Found to occur in 3.0found in release: 3.1Found to occur in 3.1frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions