<p>In this article, I'm going to share an example code for persistent bottom sheet in Flutter. Before seeing this code, here is the output of this app. Key things to note here are that touches on the empty area of the screen don't take away the bottom sheet. color: rgb(33, 37, 41); white-space: pre-wrap;](Before going further, let's get some basics on bottom sheets.color: rgb(33, 37, 41); white-space: pre-wrap;]( color: rgb(33, 37, 41); white-space: pre-wrap;](There are two kinds of bottom sheets in material design: Persistent and Modal. color: rgb(33, 37, 41); white-space: pre-wrap;]( color: rgb(33, 37, 41); white-space: pre-wrap;](In this example, we are going to see Persistent type. For Modal bottom sheet, check this article. <a href="https://fluttercentral.com/Articles/Post/1081">https://fluttercentral.com/Articles/Post/1081font-size: 1rem;</a> This gives an alternate behavior, where touches on the empty area of the screen should take away the bottom sheet font-size: 1rem;]( font-size: 1rem;](Another example, showing how to send data to the model sheet. <a href="https://fluttercentral.com/Articles/Post/1110">https://fluttercentral.com/Articles/Post/1110background-color: white; font-size: 1rem;</a>font-size: 1rem;]( ; background-color: rgb(30, 30, 30); font-family: Consolas, "Courier New", monospace; font-size: 14px; line-height: 19px; white-space: pre;](color: #569cd6;](import color: #ce9178;]('package:flutter/material.dart'; color: #569cd6;](void main() { runApp(MyApp());} color: #569cd6;](class MyApp color: #569cd6;](extends StatefulWidget { color: #569cd6;](@override _MyAppState createState() => _MyAppState();} color: #569cd6;](class _MyAppState color: #569cd6;](extends State { color: #569cd6;](final GlobalKey _scaffoldKey = GlobalKey(); color: #569cd6;](void _showBottomSheetCallback() { _scaffoldKey.currentState.showBottomSheet((BuildContext context) { color: #569cd6;](return Container( decoration: BoxDecoration( border: Border(top: BorderSide(color: Colors.black)), color: Colors.grey ), child: Padding( padding: color: #569cd6;](const EdgeInsets.all(color: #b5cea8;](32.0), child: Text(color: #ce9178;]('This is a Material persistent bottom sheet. Drag downwards to dismiss it.', textAlign: TextAlign.center, style: TextStyle( fontSize: color: #b5cea8;](24.0, ), ), ), ); }); } color: #569cd6;](@override Widget build(BuildContext context) { color: #569cd6;](return MaterialApp( home:Scaffold( key: _scaffoldKey, appBar: AppBar( title: color: #569cd6;](const Text(color: #ce9178;]('Persistent bottom sheet') ), body: Center( child: RaisedButton( onPressed: _showBottomSheetCallback, child: color: #569cd6;](const Text(color: #ce9178;]('Show Persistent Bottom Sheet') ) ) ), ); }}</p> <p>Hope this is helpful. Thanks,Srikanth</p>
How to create a persistent bottom sheet in Flutter?
This Article is posted by seven.srikanth at 6/5/2019 3:45:02 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: persistent bottom sheet; Bottom sheet that requires dragging to minimize or dismiss it;
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter