-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sheet] SheetController.(relative) animateTo is broken #412
Comments
Expanding [Sheet] using [SheetController] might not always work, e.g. you are trying to animate the sheet and expand controller at the same time (see: jamesblasco#412) You can use [addPostLayoutCallback] in order to defer your call to the moment [RenderSheetViewport] has finished [RenderSheetViewport.performLayout] Additionally you can provide [timeout] after which this callback should be called anyway incase [RenderSheetViewport.performLayout] doesn't start. Usually (this has not been super benchmarked!) layout starts under 50ms, putting 100ms to be on the safe side - YMMV
Made a PR that allows firing exactly when the layout is done using setPage(1);
Sheet.addPostLayoutCallback(() async {
await sheetController.relativeAnimateTo(
1,
duration: const Duration(milliseconds: 400),
curve: Curves.easeOutQuart,
);
setPage(0);
}); |
|
What's wrong
Calling
SheetController.relativeAnimateTo
does nothing in conditions where it should expandSteps to repro
Here's the "minimal" code I managed to put together to illustrate the issue
Launch simulator, press FAB button and watch the sheet not appear. If you switch in code from // BAD to // GOOD, hot restart, tap the button again the sheet will appear 😐
What's happening
BAD CASE
GOOD
What I think is happening
Whenever
animateTo
is called and a new widget is put at the same time, aperformLayout
insideRenderSheetViewport
will have to be called. In GOOD case this manages to happen beforebeginActivity(IdleScrollActivity#2b86b)
so the sheet "knows" how to expand. In BAD CASE out widget seems to be more complex and the dimensions are not delivered on time and the animation doesn't execute properly.I managed to workaround this by putting a delay of
150ms
beforeanimateTo
. This is obviously a non ideal HACK. Other possible hack is to use "Placeholder" widget and only replace the widget once the animation is ongoing. Related -> #360Investigating a proper fix, if anyone has any pointers - let me know.
The text was updated successfully, but these errors were encountered: