Skip to content

Instantly share code, notes, and snippets.

@LOG-TAG
Created April 27, 2020 04:17
Show Gist options
  • Save LOG-TAG/4286d09db13da8990bcd7b4c56fa22d8 to your computer and use it in GitHub Desktop.
Save LOG-TAG/4286d09db13da8990bcd7b4c56fa22d8 to your computer and use it in GitHub Desktop.
DraggableScrollableSheet
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Draggable-Scrollable'),
),
body: Stack(
children: <Widget>[
Container(
child: SingleChildScrollView(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'Draggable-Scrollable Sheet Widget Demo',
style:
TextStyle(fontSize: 25, fontWeight: FontWeight.w500),
textAlign: TextAlign.center,
),
),
),
Container(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Text(
'This is demo for draggable scrollable sheet widget. Swipe up the container.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.w400,
),
),
),
),
SizedBox(
height: 40.0,
),
Container(
child: Column(
children: <Widget>[
Container(
child: Text(
'Developed by WebToddler. ',
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
),
),
],
),
),
SizedBox(
height: 15.0,
),
Container(
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.all(16.0),
child: Container(
child: Text(
'Please \nLIKE, SHARE and \nSubscribe to my YouTube Channel.',
style: TextStyle(
fontSize: 20, fontWeight: FontWeight.w500),
),
),
),
],
),
),
],
),
),
),
DraggableScrollableSheet(
builder: (BuildContext context, ScrollController scrollController){
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(topRight: Radius.circular(30), topLeft: Radius.circular(30.0)),
color: Colors.teal[200],
),
child: ListView.builder(
controller: scrollController,
itemCount: 25,
itemBuilder: (BuildContext context, int index){
return ListTile(title : Text('Item $index'),);
}),
);
},
)
],),
),
);
}
}
@rashmisridar
Copy link

How to dismiss the DraggableScrollableSheet when it open , tried with DraggableScrollableActuator.reset(context); but in my requirement when DraggableScrollableSheet moves up need apply an opacity so used "NotificationListener".

Please help me below is my code link

https://gist.github.com/rashmisridar/9a3606684fdc79fa98a0dbe8199d9881

@JohnnyRainbow81
Copy link

DraggableScrollableSheet rebuilds all children every frame when dragged.

Please help! See my post at StackOverflow:
https://stackoverflow.com/questions/64101774/draggablescrollablesheet-rebuilds-all-children-every-frame-when-dragged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment