Addresses issue #412, adds the Sheet.addPostLayoutCallback which allows to defer SheetController calls.
Why do I need this?
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: https://github.com/jamesblasco/modal_bottom_sheet/issues/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
Sidenote
This is the best solution I could come up with, studying all the complexities of this package. This still doesn't fix the core issue, which is performing layout and expanding sheet at the same time - which just ends with setPixels(0.0) (as shown in the bug report). This PR adds rather ugly static method that provides a bit more reliable workaround than use of Future.delay.
What is this PR about?
Addresses issue #412, adds the
Sheet.addPostLayoutCallback
which allows to deferSheetController
calls.Why do I need this?
Expanding
Sheet
usingSheetController
might not always work, e.g. you are trying to animate the sheet and expand controller at the same time (see: https://github.com/jamesblasco/modal_bottom_sheet/issues/412). You can useaddPostLayoutCallback
in order to defer your call to the momentRenderSheetViewport
has finishedRenderSheetViewport.performLayout
Additionally you can providetimeout
after which this callback should be called anyway incaseRenderSheetViewport.performLayout
doesn't start. Usually (this has not been super benchmarked!) layout starts under 50ms, putting 100ms to be on the safe side - YMMVSidenote
This is the best solution I could come up with, studying all the complexities of this package. This still doesn't fix the core issue, which is performing layout and expanding sheet at the same time - which just ends with
setPixels(0.0)
(as shown in the bug report). This PR adds rather ugly static method that provides a bit more reliable workaround than use ofFuture.delay
.