Skip to content

Add lazyLoadChildren to ExpansionTile in material_ui - #12355

Open
DevarshRanpara wants to merge 1 commit into
flutter:mainfrom
DevarshRanpara:expansible-lazy-load-children
Open

Add lazyLoadChildren to ExpansionTile in material_ui#12355
DevarshRanpara wants to merge 1 commit into
flutter:mainfrom
DevarshRanpara:expansible-lazy-load-children

Conversation

@DevarshRanpara

Copy link
Copy Markdown

Summary

This PR adds a lazyLoadChildren property to ExpansionTile in the material_ui package, enabling deferred construction of children until the tile is expanded for the first time.

This is the companion PR to flutter/flutter which adds lazyLoadChildren to the underlying Expansible widget (widget layer). The ExpansionTile change is submitted here instead of flutter/flutter due to the Material library code freeze introduced in #184093.

Changes

  • Added lazyLoadChildren parameter to ExpansionTile constructor (defaults to false)
  • Added lazyLoadChildren field documentation
  • Passes lazyLoadChildren through to the underlying Expansible widget
  • Added debugFillProperties support
  • Added 3 tests covering:
    • Children deferred until first expansion (with maintainState: true)
    • Children built immediately when initiallyExpanded: true
    • Children removed on collapse when maintainState: false

Motivation

When an ExpansionTile has expensive children (e.g. heavy widgets, network images), they are currently built eagerly on first frame even if the tile is collapsed. lazyLoadChildren defers this build until the user first expands the tile, reducing initial render overhead.

Fixes flutter/flutter#184111

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation.
  • All existing and new tests are passing.

@github-actions github-actions Bot added triage-framework Should be looked at in framework triage p: material_ui labels Aug 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a lazyLoadChildren property to ExpansionTile (defaulting to false), which allows delaying the building of children until the tile is expanded for the first time when maintainState is true. It also overrides debugFillProperties to include maintainState and lazyLoadChildren, and adds comprehensive widget tests to verify the new lazy loading behavior under various configurations. There are no review comments, and I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

p: material_ui triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lazy load children of ExpansionTile when maintainState is true

1 participant