Skip to content

Fix battery chemistry dropdown layout overflow#162

Merged
446564 merged 1 commit into
zjs81:mainfrom
just-stuff-tm:fix/battery-layout-overflow
Feb 12, 2026
Merged

Fix battery chemistry dropdown layout overflow#162
446564 merged 1 commit into
zjs81:mainfrom
just-stuff-tm:fix/battery-layout-overflow

Conversation

@just-stuff-tm

Copy link
Copy Markdown
Contributor

Fix Battery Settings Layout Overflow (Dropdown Causing Vertical Text Wrap)

Problem

The Battery Chemistry row in App Settings was rendering incorrectly on smaller screens and certain device widths.

Observed issues:

  • Subtitle text (“Set per device …”) collapsed horizontally.
  • Text rendered vertically, wrapping one character per line.
  • Layout appeared broken and unreadable.

This occurred because the DropdownButton was placed inside the trailing: slot of a ListTile, alongside:

  • leading icon
  • title
  • long subtitle
  • dropdown control

The ListTile could not satisfy layout constraints, so Flutter compressed the subtitle to near-zero width, forcing character-by-character wrapping.


Root Cause

ListTile.trailing is width-constrained and intended for compact widgets (icons, switches, small controls).

Placing a wide widget like DropdownButton in trailing: caused horizontal constraint pressure. Flutter resolved this by shrinking the subtitle first, leading to vertical text collapse.


Solution

Restructured the layout as follows:

  1. Keep ListTile responsible only for:

    • leading
    • title
    • subtitle
  2. Move the dropdown out of ListTile.trailing.

  3. Render the dropdown as a full-width control beneath the tile.

  4. Use DropdownButtonFormField with:

    • isExpanded: true
    • Proper InputDecoration
    • Consistent horizontal padding

This ensures:

  • The dropdown gets full horizontal width.
  • The subtitle keeps correct wrapping behavior.
  • No layout compression occurs.
  • Material spacing remains consistent.

Implementation Changes

Before:

  • DropdownButton inside ListTile.trailing

After:

  • ListTile handles text only
  • DropdownButtonFormField rendered beneath it
  • Added isExpanded: true
  • Explicit padding for proper alignment

Result

  • Subtitle renders correctly (no vertical collapse)
  • UI matches intended Material layout
  • Improved responsiveness on smaller devices
  • Localization-safe for longer strings
  • Cleaner separation of layout responsibilities

Testing

Tested:

  • Small screen widths
  • Long device names
  • Different localization strings
  • Connected and disconnected states

No layout regressions observed.


Rationale

This aligns with Flutter layout best practices:

  • ListTile.trailing should only contain compact widgets.
  • Larger interactive controls should be placed outside of ListTile.

This change prevents future constraint-related UI issues.

@just-stuff-tm

Copy link
Copy Markdown
Contributor Author
Screenshot_20260211-064500 Screenshot_20260211-064832

@446564

446564 commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Looks good except the CI failure, also to save you time if you haven't already be sure to run dart format before committing your changes.

Comment thread lib/screens/app_settings_screen.dart Outdated
Comment thread pubspec.yaml Outdated
@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

first one didn't have the ^ arrow second does

@446564

446564 commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

first one didn't have the ^ arrow second does

It got a bit messy, we shouldn't have any changes to the lock file. Do you know how to revert changes to the one file?

@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

So it's just the battery setting fix?

@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

I may need a little bit of guidance. Github has so many features I had no idea existed.

1 similar comment
@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

I may need a little bit of guidance. Github has so many features I had no idea existed.

@446564

446564 commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

So it's just the battery setting fix?

Ya you should be able to git reset HEAD~4 then git checkout pubspec* then add and commit again. You can just force push the one commit.

@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

Done

@446564 446564 merged commit c52b19b into zjs81:main Feb 12, 2026
6 checks passed
@446564

446564 commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Awesome, thanks for the PR and congrats on your first!

@just-stuff-tm

Copy link
Copy Markdown
Contributor Author

Thanks for standing by while I learn. Looking forward to doing many more across the matrix

@just-stuff-tm just-stuff-tm deleted the fix/battery-layout-overflow branch February 12, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants