Skip to content

[Web] [HTML] Styles applied to an img tag url are incorrectly applied to other img tags with the same url #115405

@alanwutang11

Description

@alanwutang11

When using the NetworkImage widget with a specific url, and applying a ColorFilter on that image, any re-uses of that image with the same url are given the styles, such as the ColorFilter, applied to that image. This happens on initial render only. On subsequent frames, such as when re-sizing the page, the behavior gets corrected.

Code sample with same URL
//![2021-09-07_154158](https://user-images.githubusercontent.com/49754877/132296905-3a11be70-ab08-4cf2-83ae-7b317cff1d48.png)


import 'package:flutter/material.dart';

void main() {
  runApp(const ImageFilterTest());
}

class ImageFilterTest extends StatefulWidget {
  const ImageFilterTest({Key? key}) : super(key: key);

  @override
  _ImageFilterTestState createState() => _ImageFilterTestState();
}

class _ImageFilterTestState extends State<ImageFilterTest> {
  @override
  Widget build(BuildContext context) {
    return ConstrainedBox(
      constraints: BoxConstraints(minHeight: 200),
      child: Container(
        padding: EdgeInsets.all(10),
        alignment: Alignment.centerLeft,
        decoration: BoxDecoration(
          color: Colors.blueAccent,
          image: DecorationImage(
            fit: BoxFit.cover,
            image: NetworkImage(
                'https://source.unsplash.com/category/fashion/900x600'),
            colorFilter: ColorFilter.mode(
              Colors.red.withOpacity(0.8),
              BlendMode.modulate,
            ),
          ),
        ),
          child: LayoutBuilder(
            // used to get the constraints of the parent widget
             builder: (context, contstraints) {
              return ConstrainedBox(
                constraints: BoxConstraints(
                  minHeight: 200,
                  maxWidth: 400,
                ),
                child: Image.network(
                    'https://source.unsplash.com/category/fashion/900x600'),
              );
            },
          ),
      ),
    );
  }
}

With colorFilter incorrectly being applied to the smaller forefront image upon initial render:

Screen Shot 2022-11-15 at 5 32 56 PM

Expected behavior:

Screen Shot 2022-11-15 at 5 33 12 PM

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work liste: web_htmlHTML rendering backend for Webengineflutter/engine related. See also e: labels.platform-webWeb applications specifically

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions