How To Make Modal Bottom Sheet in Flutter | Mobile App Development
Modal Bottom Sheet
Source Code
import 'package:flutter/material.dart';
void main()=>runApp(MaterialApp(
debugShowCheckedModeBanner: false,
title: "Bottom Sheet",
home:ModalBottomSheet()));
class ModalBottomSheet extends StatefulWidget {
@override
_ModalBottomSheetState createState() => _ModalBottomSheetState();
}
class _ModalBottomSheetState extends State<ModalBottomSheet> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
'Modal Bottom Sheet',
style: TextStyle(color: Colors.white),
),
centerTitle: true,
),
body: Container(
alignment: Alignment.center,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"MODAL BOTTOM SHEET EXAMPLE",
style: TextStyle(
fontStyle: FontStyle.italic,
letterSpacing: 0.4,
fontWeight: FontWeight.w600),
),
SizedBox(
height: 20,
),
RaisedButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0))),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
ListTile(
leading: new Icon(Icons.photo),
title: new Text('Photo'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.music_note),
title: new Text('Music'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.videocam),
title: new Text('Video'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
leading: new Icon(Icons.share),
title: new Text('Share'),
onTap: () {
Navigator.pop(context);
},
),
],
);
});
},
padding:
EdgeInsets.only(left: 30, right: 30, top: 15, bottom: 15),
color: Colors.pink,
child: Text(
'Click Me',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w600,
letterSpacing: 0.6),
),
),
],
),
),
);
}
}
Comments
Post a Comment