This repository was archived by the owner on Apr 29, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -841,12 +841,17 @@ List<float> _computeColumnWidths(BoxConstraints constraints) {
841
841
float deficit = tableWidth - maxWidthConstraint ;
842
842
843
843
int availableColumns = this . columns ;
844
- float minimumDeficit = 0.00000001f ;
845
- while ( deficit > 0.0f && totalFlex > minimumDeficit ) {
844
+
845
+ //(Xingwei Zhu) this deficit is double and set to be 0.00000001f in flutter.
846
+ //since we use float by default, making it larger should make sense in most cases
847
+ float minimumDeficit = 0.0001f ;
848
+ while ( deficit > minimumDeficit && totalFlex > minimumDeficit ) {
846
849
float newTotalFlex = 0.0f ;
847
850
for ( int x = 0 ; x < this . columns ; x ++ ) {
848
851
if ( flexes [ x ] != null ) {
849
- float newWidth = widths [ x ] - deficit * flexes [ x ] . Value / totalFlex ;
852
+ //(Xingwei Zhu) in case deficit * flexes[x].Value / totalFlex => 0 if deficit is really small, leading to dead loop,
853
+ //we amend it with a default larger value to ensure that this loop will eventually end
854
+ float newWidth = widths [ x ] - Mathf . Max ( minimumDeficit , deficit * flexes [ x ] . Value / totalFlex ) ;
850
855
D . assert ( newWidth . isFinite ( ) ) ;
851
856
if ( newWidth <= minWidths [ x ] ) {
852
857
deficit -= widths [ x ] - minWidths [ x ] ;
You can’t perform that action at this time.
0 commit comments