【发布时间】:2021-02-02 06:33:31
【问题描述】:
我想在按下某个按钮时更改 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,
我做错了什么
【问题讨论】: