Skip to content

Instantly share code, notes, and snippets.

@MarcinHradowicz
Last active November 13, 2022 14:51
Show Gist options
  • Save MarcinHradowicz/756ef21355eed535ab275eb56cbf8a49 to your computer and use it in GitHub Desktop.
Save MarcinHradowicz/756ef21355eed535ab275eb56cbf8a49 to your computer and use it in GitHub Desktop.
build in _ImprovedDraggableScrollableSheetState
class _ImprovedDraggableScrollableSheetState extends State<ImprovedDraggableScrollableSheet> {
@override
Widget build(BuildContext context) {
final MediaQueryData mediaQueryData = MediaQuery.of(context);
final double heightOfDevice = mediaQueryData.size.height;
final initialChildSize =
(commentsHeaderHeight + mediaQueryData.viewPadding.bottom + mediaQueryData.viewPadding.top) / heightOfDevice;
return DraggableScrollableSheet(
initialChildSize: initialChildSize,
minChildSize: initialChildSize,
maxChildSize: 1.0,
builder: (context, scrollController) {
return Container(
padding: EdgeInsets.only(bottom: mediaQueryData.viewPadding.bottom),
margin: EdgeInsets.only(top: mediaQueryData.viewPadding.top),
decoration: const BoxDecoration(
color: Color(0xffB1B2ff),
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
_StreamerPageCommentsHeader(key: commentsHeaderKey, scrollController: scrollController),
Expanded(
child: ListView.builder(
padding: EdgeInsets.zero,
itemCount: 30,
itemBuilder: (context, index) => Container(
color: index % 2 == 0 ? const Color(0xffAAC4FF) : const Color(0xffD2DAFF),
child: ListTile(title: Text('Comment $index')),
),
),
)
],
),
);
},
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment