gpt4 book ai didi

Flutter 动态改变 DraggableScrollableSheet 的高度

转载 作者:行者123 更新时间:2023-12-05 03:45:11 25 4
gpt4 key购买 nike

我想在按下某个按钮时更改 DraggableScrollableSheet 的高度。到目前为止,这就是我所拥有的

..other code up here...
double _sheetSize=0.8;

@override
Widget build(BuildContext context) {
return DraggableScrollableSheet(
initialChildSize: 0.29,
minChildSize: 0.05,
maxChildSize: _sheetSize,
builder: (BuildContext context, _myScrollController) {
return Container(
padding:EdgeInsets.symmetric(horizontal: 40,vertical: 10),
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(.8),
offset: Offset(3, 2),
blurRadius: 7)
]),
child: PageView(
physics: NeverScrollableScrollPhysics(),
controller: _stepController,
children: [
NotificationListener<NextStep>(
child: SelectTimeWidget(myScrollController: _myScrollController),
onNotification: (notification) {
if(notification.moveToNextStep){
moveToNextStep();
setState(() {
_sheetSize=0.5;
});
}else{
moveToPreviousStep();
}
return null;
}
),
...some other code here...

在这个小部件中,我使用了一个通知监听器来触发一个我想要更改工作表高度的事件

              NotificationListener<NextStep>(
child: SelectTimeWidget(myScrollController: _myScrollController),
onNotification: (notification) {
if(notification.moveToNextStep){
moveToNextStep();
setState(() {
_sheetSize=0.5;
});
}else{
moveToPreviousStep();
}
return null;
}
),

纸张高度

maxChildSize: _sheetSize,

我哪里做错了

最佳答案

经过一些真正的努力,我后来发现在发布时不可能为 DraggableScrollableSheet Api 执行此操作,但还有另一种方法可以使用包实现此操作:sliding_up_panel .

关于Flutter 动态改变 DraggableScrollableSheet 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66004681/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com