Bottomsheet in flutter
Bottom Sheet in FLUTTER
Bottom Sheet is Most beautiful cmponents from material design and it's use like a modal
its open from bottom side in the screen and showing any details bottomsheet is used
In flutter very easy to use of bottomsheet
In here we are going to use showModalBottomSheet method to popup bottom sheet . In that method there are two required parameters
1. Build context
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-2901888179579254",
enable_page_level_ads: true
});
2.Widget builder
following full code of bottom sheet:
| import 'package:flutter/material.dart'; | |
| void main() => runApp(new MyApp()); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return new MaterialApp( | |
| title: 'Flutter Demo', | |
| theme: new ThemeData( | |
| primarySwatch: Colors.blue, | |
| ), | |
| home: new bottomsheet(title: 'Flutter Bottom sheet'), | |
| ); | |
| } | |
| } | |
| class bottomsheetextends StatefulWidget { | |
| bottom({Key key, this.title}) : super(key: key); | |
| final String title; | |
| @override | |
| bottomsheetState createState() => new bottomsheetState(); | |
| } | |
| class bottomsheetState extends State<bottomsheet> { | |
| @override | |
| Widget build(BuildContext context) { | |
| return new Scaffold( | |
| appBar: new AppBar( | |
| title: new Text(widget.title), | |
| ), | |
| floatingActionButton: new FloatingActionButton( | |
| onPressed: (){ | |
| _settingModalBottomSheet(context); | |
| }, | |
| child: new Icon(Icons.add), | |
| ), | |
| ); | |
| } | |
| } | |
| void _settingModalBottomSheet(context){ | |
| showModalBottomSheet( | |
| context: context, | |
| builder: (BuildContext bc){ | |
| return Container( | |
| child: new Wrap( | |
| children: <Widget>[ | |
| new ListTile( | |
| leading: new Icon(Icons.music_note), | |
| title: new Text('Music'), | |
| onTap: () => {} | |
| ), | |
| new ListTile( | |
| leading: new Icon(Icons.videocam), | |
| title: new Text('Video'), | |
| onTap: () => {}, | |
| ), | |
| ], | |
| ), | |
| ); | |
| } | |
| ); | |
}
OUTPUT: |



Comments
Post a Comment