Repository navigation
Commit 054d9d1
authored
[cupertino_ui] Fix CupertinoSheetRoute throwing when a drag ends during a pending relayout (flutter#13316)
Dragging a `CupertinoSheetRoute` converts drag deltas and the release velocity into fractions of the sheet's height. Both drag paths read that height from `context.size`: `_CupertinoDragGestureDetectorState.sheetHeight` for regular sheets, and `_dragUpdate` / `_handleDragEnd` in `_CupertinoDraggableScrollableSheetState` for sheets built with `scrollableBuilder`. `Element.size` asserts when the render object is dirty for layout, so a drag that ends while a relayout is pending throws `Cannot get size from a render object that has been marked dirty for layout.` The reporter saw it cascade into `_drag == null` asserts in `ScrollableState`, after which the sheet stopped responding. In release the assert is stripped and the read returns the last laid out size.
The fix reads the height from the `RenderBox` directly. That's the size the sheet was last laid out at, which is the size the drag was made against, and it's what release builds were already using. The Material `BottomSheet` reads its height for drag updates and fling velocity the same way (`_childHeight`).
## Tests
Two regression tests, one per drag path. Each starts a partial drag, marks the box the sheet measures as dirty, and releases before the next frame. Both fail on `main` with the assertion above, and both pass with the fix, with the sheet settling back to where it started. The rest of `sheet_test.dart` passes as well (44 tests in total).
One limitation: the reporter hit this on a device when the keyboard was dismissed mid-drag. Changing the view insets mid-drag in a widget test doesn't reproduce it, because the relayout that follows lands before the pointer up. So the tests set up the condition from the reporter's stack trace directly, not the keyboard sequence.
Fixes flutter/flutter#194681
## Pre-Review Checklist
I used AI tooling while working on this, and reviewed and tested all of it myself.
[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.1 parent 7729836 commit 054d9d1
3 files changed
Lines changed: 92 additions & 4 deletions
File tree
- packages/cupertino_ui
- lib/src
- pending_changelogs
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1014 | 1014 | | |
1015 | 1015 | | |
1016 | 1016 | | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
1017 | 1024 | | |
1018 | 1025 | | |
1019 | 1026 | | |
| |||
1040 | 1047 | | |
1041 | 1048 | | |
1042 | 1049 | | |
1043 | | - | |
1044 | | - | |
1045 | 1050 | | |
1046 | 1051 | | |
1047 | 1052 | | |
| |||
1089 | 1094 | | |
1090 | 1095 | | |
1091 | 1096 | | |
| 1097 | + | |
1092 | 1098 | | |
1093 | 1099 | | |
1094 | 1100 | | |
| |||
1104 | 1110 | | |
1105 | 1111 | | |
1106 | 1112 | | |
| 1113 | + | |
1107 | 1114 | | |
1108 | 1115 | | |
1109 | 1116 | | |
| |||
1450 | 1457 | | |
1451 | 1458 | | |
1452 | 1459 | | |
| 1460 | + | |
1453 | 1461 | | |
1454 | | - | |
| 1462 | + | |
1455 | 1463 | | |
1456 | 1464 | | |
1457 | 1465 | | |
| |||
1460 | 1468 | | |
1461 | 1469 | | |
1462 | 1470 | | |
1463 | | - | |
| 1471 | + | |
1464 | 1472 | | |
1465 | 1473 | | |
1466 | 1474 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1625 | 1625 | | |
1626 | 1626 | | |
1627 | 1627 | | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
1628 | 1667 | | |
1629 | 1668 | | |
1630 | 1669 | | |
| |||
1865 | 1904 | | |
1866 | 1905 | | |
1867 | 1906 | | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
| 1924 | + | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
| 1941 | + | |
| 1942 | + | |
| 1943 | + | |
| 1944 | + | |
1868 | 1945 | | |
1869 | 1946 | | |
1870 | 1947 | | |
| |||
0 commit comments