Choose between Image and StatefulImage widgets
masterDepending on your performance and UI requirements, choose one of the following widgets:
Image widget
- Behavior: Has a fixed size in rows/columns. If the image exceeds the pixel area of the cells, it is scaled down proportionally to "fit" once during the creation of the
Protocol. - Pros: It is stateless (immediate-mode), meaning it never blocks the rendering thread/task.
- Clipping: Use
Image::allow_clippingto control what happens when the image does not fit the render area.
StatefulImage widget
- Behavior: Adapts to its render area at render-time. It can be configured to fit, crop, or scale to the available area.
- Pros: Highly flexible for dynamic layouts.
- Cons: It is stateful (requires
render_stateful_widget) and the resizing/encoding process is blocking. - Best Practice: Always offload
StatefulImageoperations to another thread or async task (e.g., usingthread::ThreadProtocol) to keep the UI responsive.