英文:
Is it possible to specify BouncingScrollPhysics for ScrollPhysics in the Flutter DraggableScrollableSheet widget?
问题
根据我所研究的情况,似乎无法在DraggableScrollableSheet小部件中指定BouncingScrollPhysics作为ScrollPhysics。如果有人知道,请提供在DraggableScrollableSheet小部件中指定BouncingScrollPhysics为ScrollPhysics的操作说明。
英文:
As far as I have researched, it doesn't seem possible to specify BouncingScrollPhysics for ScrollPhysics in the DraggableScrollableSheet widget. If anyone knows, could you please provide instructions on how to specify BouncingScrollPhysics for ScrollPhysics in the DraggableScrollableSheet widget?
答案1
得分: 1
你不能将物理效果分配给DraggableScrollableSheet。
你应该在DraggableScrollableSheet的构建器中使用一个可滚动的小部件,并将构建器中的scroll controller
分配给可滚动小部件。请参考下面的示例代码:
DraggableScrollableSheet(
initialChildSize: 0.1,
minChildSize: 0.1,
maxChildSize: 1,
expand: false,
builder: (_, scrollController) => ListView(
controller: scrollController, //在这里分配控制器
physics: const BouncingScrollPhysics(),
),
);
如上所示,我有一个ListView,它使用了来自DraggableScrollableSheet的滚动控制器,并将其设置为BouncingScrollPhysics()。
英文:
You cannot assign physics to DraggableScrollableSheet.
What you should do is to have a scrollable widget in the builder of the DraggableScrollableSheet and assign the scroll controller
from the builder to the scrollable. See the below snippet:
DraggableScrollableSheet(
initialChildSize: 0.1,
minChildSize: 0.1,
maxChildSize: 1,
expand: false,
builder: (_, scrollController) => ListView(
controller: scrollController, //assign the controller here
physics: const BouncingScrollPhysics(),
),
);
As shown above, i have a listview that uses the scroll controller from the DraggableScrollableSheet and gave it BouncingScrollPhysics().
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论