Navigation - DraggableScrollableSheet

 DraggableScrollableSheet




Source Code


import 'package:flutter/material.dart';


void main() {
runApp( MaterialApp(
title:" DraggableScrollableSheet ",
home:Scaffold(appBar: AppBar(title: Text(' DraggableScrollableSheet ',),),
body: Material(
child: Center(
child:
DraggableScrollableSheetExample()
,
),
) ,
),
));
}




class DraggableScrollableSheetExample extends StatelessWidget {
const DraggableScrollableSheetExample({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('DraggableScrollableSheet'),
),
body: Stack(
children: <Widget>[
SizedBox.expand(
child: Container(
color: Colors.red,
),
),
_buildDraggableScrollableSheet(),
],
),
);
}

DraggableScrollableSheet _buildDraggableScrollableSheet() {
return DraggableScrollableSheet(
initialChildSize: 0.2,
minChildSize: 0.2,
maxChildSize: 0.8,
builder: (BuildContext context, ScrollController scrollController) {
return Container(
decoration: const BoxDecoration(
color: Colors.blue,
// border: Border.all(color: Colors.blue, width: 2),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
topRight: Radius.circular(8),
),
),
child: Scrollbar(
child: ListView.builder(
controller: scrollController,
itemCount: 25,
itemBuilder: (BuildContext context, int index) {
return ListTile(
leading: const Icon(Icons.ac_unit),
title: Text('Item $index'),
);
},
),
),
);
},
);
}
}


Comments