A Pen by Eshiet Ekemini on CodePen.
Created
June 10, 2020 15:07
-
-
Save Ekeminie/bf83b8dd60c57b635c477e83eb8a08a3 to your computer and use it in GitHub Desktop.
WNrrMXE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Flutter Demo', | |
theme: new ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: new MyHomePage(title: 'Flutter Bottom sheet'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => new _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); | |
void _showBottomSheetCallback() { | |
_scaffoldKey.currentState.showBottomSheet<void>((BuildContext context) { | |
return Container( | |
decoration: BoxDecoration( | |
border: Border(top: BorderSide(color: Colors.black)), | |
color: Colors.grey), | |
child: Padding( | |
padding: const EdgeInsets.all(32.0), | |
child: Text( | |
'This is a persistent bottom sheet. Drag downwards to dismiss it.', | |
textAlign: TextAlign.center, | |
style: TextStyle( | |
fontSize: 24.0, | |
), | |
), | |
), | |
); | |
}); | |
} | |
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: () => {}, | |
), | |
], | |
), | |
); | |
}); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
key: _scaffoldKey, | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
RaisedButton( | |
onPressed: _showBottomSheetCallback, | |
child: Text('Persistent BottomSheet')), | |
RaisedButton( | |
onPressed: () { | |
_settingModalBottomSheet(context); | |
}, | |
child: const Text('Modal BottomSheet')) | |
]))); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment