Skip to content

bug: Container not displayed when adding image instance attribute in init() #6645

Description

@tr31zh

Duplicate Check

Describe the bug

Adding an image as an instance attribute in the init method of a custom Container will make the container be displayed as a grey rectangle even if the image is not added to the container's content.

Code sample

Code
import flet as ft

@ft.control
class ImageDemo(ft.Container):
    def init(self):
        self.image = ft.Image(src="https://flet.dev/img/logo.svg")
        self.content = ft.Column(controls=[ft.Text("Foo")])


def main(page: ft.Page):
    page.title = "Image container"
    calc = ImageDemo()
    page.add(calc)


ft.run(main)

To reproduce

Run the script either in as an app

python run image_demo.py

Or as webapp

python run --web image_demo.py

Expected behavior

A label with the text "Foo" should be displayed in the window or web page.

Screenshots / Videos

Captures Image

[Upload media here]

Operating System

macOS

Operating system details

Tahoe 26.5.1

Flet version

0.85.3

Regression

I'm not sure / I don't know

Suggestions

No response

Logs

Logs
> uv run flet run --web  hello.py       
http://127.0.0.1:65003

Additional details

If the image is directly created inside the controls argumment or is not created at all everything works as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions