You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So, AutoSizeText does not work using IntrinsicWidth or IntrinsicHeight because:
LayoutBuilder does not support returning intrinsic dimensions.
You might say: just do not use either of these widgets, however, I believe that that is a naive approach. The reason for this is that intrinsic sizing is an integral part of the Flutter framework. It can be used anywhere.
Example
We have a custom table widget. And because tables are intricate things, they will rely on intrisic sizes. We do not use IntrinsicWidth or IntrinsicHeight - we simply use the RenderBox contract:
There are four methods to implement for intrinsic sizing, to compute the minimum and maximum intrinsic width and height of the box. The documentation for these methods discusses the protocol in detail: computeMinIntrinsicWidth, computeMaxIntrinsicWidth, computeMinIntrinsicHeight, computeMaxIntrinsicHeight.
Consequences
If you have anyAutoSizeText widget in a widget that makes use of the intrinsic sizing contract, AutoSizeText will completely break that widget because it uses LayoutBuilder.
Solution
Here is a solution that could work (have not thought it through yet):
We should probably rewrite AutoSizeText to ditchLayoutBuilder.
We could do this by writing our own RenderBox (leaf render object) subclass. This would allow us to fulfill the intrinsic sizing contract and also properly perform the layout.
We would be able to directly access the text painter instead of proxying through the layout builder.
@creativecreatorormaybenot@luqmanhakem This seems like a problem we should fix. I probably won't have time to implement it in the near future but I'll review any PR proposal as quickly as possible.
The problem
So,
AutoSizeText
does not work usingIntrinsicWidth
orIntrinsicHeight
because:You might say: just do not use either of these widgets, however, I believe that that is a naive approach. The reason for this is that intrinsic sizing is an integral part of the Flutter framework. It can be used anywhere.
Example
We have a custom table widget. And because tables are intricate things, they will rely on intrisic sizes. We do not use
IntrinsicWidth
orIntrinsicHeight
- we simply use theRenderBox
contract:Consequences
If you have any
AutoSizeText
widget in a widget that makes use of the intrinsic sizing contract,AutoSizeText
will completely break that widget because it usesLayoutBuilder
.Solution
Here is a solution that could work (have not thought it through yet):
We should probably rewrite
AutoSizeText
to ditchLayoutBuilder
.We could do this by writing our own
RenderBox
(leaf render object) subclass. This would allow us to fulfill the intrinsic sizing contract and also properly perform the layout.We would be able to directly access the text painter instead of proxying through the layout builder.
Related issues
The text was updated successfully, but these errors were encountered: