Skip to content
Snippets Groups Projects
Unverified Commit ab70aea3 authored by Qun Cheng's avatar Qun Cheng Committed by GitHub
Browse files

Text should still be centered when search bar height is less than 48 (#128068)

Fixes #127092

This fix can solve the alignment issue in `SearchBar` but we still need to investigate the root cause for the `TextField`. The 
text baseline of `TextField` doesn't change when the height is less than 48 and greater than 40. The problem should be related to the `minContainerHeight` which is 48 by default but the `contentHeight` has become smaller than this min value already. Setting `isDense`/`isCollapsed` to true gives the `minContainerHeight` a smaller number which is 0.0: https://github.com/flutter/flutter/blob/ff33555b239de4c17e7149db17eb70bcf5dee215/packages/flutter/lib/src/material/input_decorator.dart#L1086

Since [`isDense`](https://github.com/flutter/flutter/blob/ff33555b239de4c17e7149db17eb70bcf5dee215/packages/flutter/lib/src/material/input_decorator.dart#L3907) is used for the case where the text field has less vertical space, I just use this property in SearchBar.

https://github.com/flutter/flutter/assets/36861262/6ddc8e90-1b47-4dd5-9a57-59b86cafec6d

This is a demo to show the text baseline that doesn't change when we set the text field height under 48.
https://github.com/flutter/flutter/assets/36861262/ce2ee815-f1f5-493a-930e-0540a627bec8
parent 4a8780d2
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment