Showmodalbottomsheet自适应尺寸颤动
我有下一个问题,即使这里有一个空白空间
Future<void> buildScrollableSheet([Widget? header]) {
return showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => makeDismissible(
child: DraggableScrollableSheet(
initialChildSize: 0.3,
maxChildSize: 0.9, // this one should be adaptive
builder: (_, controller) => Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
top: Radius.circular(25),
),
),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Padding(
padding: EdgeInsets.all(24),
child: Center(
child: Text(
'My header',
style: TextStyle(
color: Color(0xff757575),
fontSize: 14,
),
),
),
),
Flexible(
child: Material(
color: Colors.white,
child: ListView(
shrinkWrap: true,
controller: controller,
children: [
SimpleHeader(
title: 'title',
text: 'text',
),
SimpleHeader(
title: 'title',
text: 'text',
),
SimpleHeader(
title: 'title',
text: 'text',
),
],
),
),
),
],
),
),
),
),
);
}
,您可以看到MaxChildSize设置为0.9,这是0.9,这是listView
,即使您可以看到MaxChildSize ,也可以看到MaxChildSize的设置为0.9,即使您可以看到MaxChildSize ,也可以看到MaxChildSize,即,但是在这种情况下,只有3个元素,我想防止滚动到全尺寸,也可以将initaryChildSize
设置为Childs尺寸,因此,如果我有大量的项目列表总是会打开。 谢谢你!
I have the next problem, having a little number of children allows users to scroll even though there is an empty space
Future<void> buildScrollableSheet([Widget? header]) {
return showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor: Colors.transparent,
builder: (context) => makeDismissible(
child: DraggableScrollableSheet(
initialChildSize: 0.3,
maxChildSize: 0.9, // this one should be adaptive
builder: (_, controller) => Container(
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.vertical(
top: Radius.circular(25),
),
),
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column(
// crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Padding(
padding: EdgeInsets.all(24),
child: Center(
child: Text(
'My header',
style: TextStyle(
color: Color(0xff757575),
fontSize: 14,
),
),
),
),
Flexible(
child: Material(
color: Colors.white,
child: ListView(
shrinkWrap: true,
controller: controller,
children: [
SimpleHeader(
title: 'title',
text: 'text',
),
SimpleHeader(
title: 'title',
text: 'text',
),
SimpleHeader(
title: 'title',
text: 'text',
),
],
),
),
),
],
),
),
),
),
);
}
Here you can see maxChildSize is being set as 0.9 which is fine with a lot of children inside ListView
, but in this case, there are only 3 elements and I want to prevent scrolling to full size, also it would be great to set initialChildSize
to childs size, so if I have a huge list of items it would always open full.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论