Vertically placing two trailing icon in List Tile - flutter

I have placed two arrow icons vertically in a column of a list-tile using trailing option. But I am not able to get the desired rendering. I used the flexible widget to adjust them but the top icon is not moving upwards.
The layout I am getting
This is my code:
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
),
body: ListView(children: <Widget>[
new Container(
color: Colors.lightBlue,
child: ListTile(
title: Text("This is a title"),
subtitle: new Text("This is subtitle"),
trailing: new Container(
color: Colors.yellow,
child: Column(
children: <Widget>[
new Flexible(
flex: 6,
child: new IconButton(
icon: Icon(Icons.arrow_drop_up), onPressed: () {})
),
new Flexible(
flex: 4,
child: new Text("1")
),
new Flexible(
flex: 5,
child: new IconButton(
icon: Icon(Icons.arrow_drop_down),
onPressed: () {})
),
],
),
),
),
)
]),
),
);
}
}
I have the content in the container to show the colours. I want the up arrow at the top of the yellow box.
Please help.

Try this way. But no matter how you do it, the arrows will be very small and inconvenient to use.
Try to create your own widget with a different design to make it more convenient for the user. Maybe something like this.
ListView(children: <Widget>[
new Container(
color: Colors.lightBlue,
child: ListTile(
title: Text("This is a title"),
subtitle: new Text("This is subtitle"),
trailing: new Container(
width: 150,
child: Row(
children: <Widget>[
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(5.0),
topLeft: Radius.circular(5.0)),
color: Colors.black.withOpacity(0.7),
),
child: Center(
child: Icon(Icons.remove,color: Colors.white),
),
width: 50,
),
Container(
width: 50,
color: Colors.white,
child: Center(
child: Text('0'),
),
),
Container(
width: 50,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
bottomRight: Radius.circular(5.0),
topRight: Radius.circular(5.0)),
color: Colors.black.withOpacity(0.7),
),
child: Center(
child: Icon(Icons.add, color: Colors.white,),
),
)
],
)),
),
)
]),
Your code.
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Container(
child: Icon(
Icons.arrow_drop_up,
size: 21,
)),
Text(
"1",
style: TextStyle(fontSize: 12),
),
Container(
child: Icon(
Icons.arrow_drop_down,
size: 21,
)),
],
),

Related

How to make this container in flutter?

enter image description here
I wan to make this container and I have try it making in container by dividing it in 2 row. After that I divide first row in 3 row again but It was not same design made. So, please help me to make this.
Take a look at https://medium.com/flutter-community/flutter-layout-cheat-sheet-5363348d037e. It's great tutorial for Flutter layout positioning. Have fun!
import 'package:flutter/material.dart';
const Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(
scaffoldBackgroundColor: darkBlue,
),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Container(
width: 300,
height: 150,
padding: const EdgeInsets.symmetric(horizontal: 15.0, vertical: 5.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.0),
color: const Color(0xff272830),
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
header(),
const Text(
'To register, fill out the form in the sign-up section above. In order to activate your account, we will send you an invitation email that you must confirm'),
],
),
);
}
Widget header() {
return Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [
Row(mainAxisSize: MainAxisSize.min, children: [
ClipOval(
child: Image.network(
'https://dt2sdf0db8zob.cloudfront.net/wp-content/uploads/2019/12/9-Best-Online-Avatars-and-How-to-Make-Your-Own-for-Free-image1-5.png',
width: 40,
height: 40,
fit: BoxFit.cover,
),
),
const SizedBox(width: 5),
Text('SIGN UP'),
]),
SizedBox(
height: 40,
child: OutlinedButton(
onPressed: () {},
child: const Text('Step 1',
style: TextStyle(
color: Colors.white,
)),
style: OutlinedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
)
]);
}
}
Try this
Column(
children: [
Container(
margin: EdgeInsets.fromLTRB(12, 12, 12, 12),
padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.all(
Radius.circular(20),
)),
child: Column(
children: [
Row(
children: [
CircleAvatar(
backgroundImage: NetworkImage(
'https://picsum.photos/id/237/200/300'),
),
SizedBox(
width: 20,
),
Expanded(
child: Text(
"SIGN UP",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold),
),
),
Container(
padding: EdgeInsets.fromLTRB(24, 12, 24, 12),
decoration: BoxDecoration(
color: Colors.grey,
border: Border.all(
color: Colors.white,
),
borderRadius: BorderRadius.all(
Radius.circular(16),
)),
child: Text("Step 1"),
),
],
),
SizedBox(
height: 8,
),
Container(
child: Text(
"To register, fill out the form in the sign-up section above. In order to activate your account, we will send you and activation email that you must confirm"),
),
],
),
)
],
),
Instead of container, you can do it by using Card. Take a look at this example from https://api.flutter.dev/flutter/material/Card-class.html
Card(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const ListTile(
leading: Icon(Icons.album),
title: Text('The Enchanted Nightingale'),
subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.'),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
TextButton(
child: const Text('BUY TICKETS'),
onPressed: () {/* ... */},
),
const SizedBox(width: 8),
TextButton(
child: const Text('LISTEN'),
onPressed: () {/* ... */},
),
const SizedBox(width: 8),
],
),
],
),
),

How to open drawer with iconbutton in Flutter?

Well, I was trying to create my custom appbar but I keep editing my column widget with properties I wanted in my appbar and it worked same as I wanted the appbar(as you can see in image) so I thought I dont need a appbar now. But now I want to implement a drawer which can be access by my iconbutton (which is implemented in top left corner of my widget). Actually drawer is implemented bcoz i can use it with sliding action, but I think its hidden behind my widget! I searched on internet and found some codes but since I dont have deep knowledge of any other programming knowledge so its little hard to understand the syntax for me. How can I access this drawer with my IconButton???
enter image description here
This is my page source code. NOTE: sorry i could not update the upper part of my bcoz i dont know how to format it in stackoverflow so its getting input as text instead of code snippet so I am avoiding it
return Scaffold(
backgroundColor: Colors.white,
drawer: CstmDrawer(),
body: SafeArea(
child: Column(
children: [
Row(
children: [
Container(
height: 150.0,
width: MediaQuery.of(context).size.width * 1.0,
child: Stack(
children: [
Container(
height: 130.0,
width: MediaQuery.of(context).size.width * 1.0,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.vertical(
bottom: Radius.elliptical(
MediaQuery.of(context).size.width, 100.0),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
IconButton(
onPressed: () {
Scaffold.of(context).openDrawer(); //I found this code on internet but it gives error "Scaffold.of() called with a context that does not contain a Scaffold."
},
icon: Icon(Icons.menu),
),
Container(
child: Row(
children: [
IconButton(
onPressed: () {},
icon: Icon(
Icons.notifications_active_outlined)),
IconButton(
onPressed: () {},
icon: Icon(Icons.shopping_cart_outlined)),
],
),
),
],
),
),
Positioned(
bottom: 20.0,
right: MediaQuery.of(context).size.width * 0.07,
child: Container(
height: 40.0,
width: MediaQuery.of(context).size.width * 0.85,
child: Theme(
data: ThemeData(primaryColor: Colors.black),
child: TextField(
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
prefixIcon: Icon(Icons.search),
hintText: "Search Here",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
),
),
),
),
),
),
],
),
),
],
),
],
),
),
);
Drawer source code.
return Drawer(
elevation: 16.0,
child: Column(
children: [
UserAccountsDrawerHeader(
onDetailsPressed: (){},
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.white,
child: IconButton(
onPressed: (){},
tooltip: "Add Photo",
splashColor: Colors.black,
icon: Icon(
Icons.add_a_photo_rounded,
),
),
),
accountName: Text(
"My Name"
),
accountEmail: Text(
"myemail#gmail.com",
),
),
ListTile(
//tileColor: Colors.green,
onTap: (){},
leading: Icon(Icons.person),
hoverColor: Colors.grey,
title: Text("My Account"),
),
Divider(),
ListTile(
onTap: (){},
leading: Icon(Icons.shopping_cart_outlined),
hoverColor: Colors.grey,
title: Text("Cart"),
),
Divider(),
ListTile(
onTap: (){},
leading: Icon(Icons.storefront_sharp),
hoverColor: Colors.grey,
title: Text("Shop"),
),
Divider(),
ListTile(
onTap: (){},
leading: Icon(Icons.location_on_outlined),
hoverColor: Colors.grey,
title: Text("Map"),
),
Divider(
thickness: 2.0,
),
ListTile(
onTap: (){},
leading: Icon(Icons.settings),
hoverColor: Colors.grey,
title: Text("Settings"),
),
Divider(),
ListTile(
onTap: (){},
leading: Icon(Icons.logout),
hoverColor: Colors.grey,
title: Text("Logout"),
),
],
),
);
The issue is that your context does not contains yet the data from your Scaffold, the workaround you can apply would be to use a GlobalKey to refer to your current ScaffoldState:
class MyWidget extends StatelessWidget {
final _scaffoldKey = GlobalKey<ScaffoldState>();
#override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
backgroundColor: Colors.white,
drawer: CstmDrawer(),
body: SafeArea(
child: Column(
children: [
Row(
children: [
Container(
height: 150.0,
width: MediaQuery.of(context).size.width * 1.0,
child: Stack(
children: [
Container(
height: 130.0,
width: MediaQuery.of(context).size.width * 1.0,
decoration: BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.vertical(
bottom: Radius.elliptical(
MediaQuery.of(context).size.width, 100.0),
),
),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
/// Use the _scaffoldKey to call openDrawer()
IconButton(
onPressed: () =>
_scaffoldKey.currentState.openDrawer(),
icon: Icon(Icons.menu),
),
Container(
child: Row(
children: [
IconButton(
onPressed: () {},
icon: Icon(
Icons.notifications_active_outlined)),
IconButton(
onPressed: () {},
icon: Icon(Icons.shopping_cart_outlined)),
],
),
),
],
),
),
Positioned(
bottom: 20.0,
right: MediaQuery.of(context).size.width * 0.07,
child: Container(
height: 40.0,
width: MediaQuery.of(context).size.width * 0.85,
child: Theme(
data: ThemeData(primaryColor: Colors.black),
child: TextField(
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
prefixIcon: Icon(Icons.search),
hintText: "Search Here",
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(30.0),
),
),
),
),
),
),
],
),
),
],
),
],
),
),
);
}
}
Here the solution is to use _scaffoldKey to call openDrawer() so instead of doing Scaffold.of(context).openDrawer() you will do _scaffoldKey.currentState.openDrawer(), and do not forget to assign the key to your Scaffold, by doing key: _scaffoldKey.
You can use this I guess!
IconButton(
icon: Icon(Icons.menu),
onPressed: () => Scaffold.of(context).openDrawer()
)

how to remove bottom space between bottom of the screen and bottom bar?

How to remove white space between bottom bar and bottom of the screen. I also try apply padding or margin in bottom container but its not working . please help me how to resolve this problem .
hey help me i am afraid about this error . it takes my most of the time but i cant solve it. please help me.
Its my code
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:provider/provider.dart';
import 'package:grk_001/Provider/products.dart';
class ProductDetails extends StatelessWidget {
static const String routename = 'ProductDetails';
#override
Widget build(BuildContext context) {
final devicesize = MediaQuery.of(context).size;
final Productid = ModalRoute.of(context).settings.arguments as String;
final loadedproduct = Provider.of<Products>(
context,
).findByid(Productid);
return SafeArea(
maintainBottomViewPadding: true,
child: Scaffold(
appBar: AppBar(
title: Text(loadedproduct.title == null ? '' : loadedproduct.title),
),
body: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
width: double.infinity,
height: 300,
child: Image.network(
loadedproduct.imageUrl,
fit: BoxFit.cover,
),
),
SizedBox(
height: 15.0,
),
Text(
'₹${loadedproduct.price}',
style: TextStyle(fontSize: 30.0),
),
SizedBox(
height: 10.0,
),
Text(
loadedproduct.description,
softWrap: true,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 20.0),
),
Row(
children: <Widget>[
Expanded(
child: FlatButton.icon(
onPressed: () {},
icon: Icon(
Icons.arrow_drop_down,
color: Colors.pink,
),
label: Text(
'Quantity',
style: TextStyle(color: Colors.pink),
)),
),
Expanded(
child: FlatButton.icon(
onPressed: () {},
icon: Icon(
Icons.arrow_drop_down,
color: Colors.pink,
),
label: Text(
'Color',
style: TextStyle(color: Colors.pink),
),
),
)
],
)
],
),
),
Container(
padding: EdgeInsets.zero,
margin: EdgeInsets.zero,
width: double.infinity,
decoration: BoxDecoration(),
child: Row(
children: <Widget>[
Expanded(
flex: 5,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Colors.pink,
onPressed: () {},
child: Text('BUY NOW'),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.favorite,
size: 37.0,
color: Colors.red,
),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.shopping_cart,
size: 37.0,
color: Colors.red,
),
),
),
),
],
),
)
],
),
),
),
);
}
}
At last, found your problem.
The problem is with your 'BUY NOW' button! It occupies extra height so that it will visible to be high up from the bottom.
Since your icon's size is 37, a height greater than 37 would be preferred.
Set it for both parent Container and Button's Container.
Also, make a note of crossAxisAlignment of the Row.
Do something like this to your 'BUY NOW' button,
Container(
width: MediaQuery.of(context).size.width,
height: 40.0,
color: Colors.green,
child: Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Expanded(
flex: 5,
child: Container(
height: 40.0,
child: FlatButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
),
color: Colors.pink,
onPressed: () {},
child: Text('BUY NOW'),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.favorite,
size: 37.0,
color: Colors.red,
),
),
),
),
Expanded(
flex: 1,
child: InkWell(
onTap: () {},
child: Container(
child: Icon(
Icons.shopping_cart,
size: 37.0,
color: Colors.red,
),
),
),
),
],
),
)
Hope this solves your issue.

How to show a Container fixed at bottom of screen without using bottom navigation bar in Flutter?

In my flutter project, I have a container with some icons and text below them. I want this entire container to be fixed at bottom of the screen without using bottom navigation bar like the below image-
So, I need an entire example to fix that container at bottom and keep my other components inside body with a scroll view.
Ok,
Here you go....
return Scaffold(
appBar: AppBar(
title: Text("Header"),
),
body: Column(
children: <Widget>[
Expanded(
child: Container(
alignment: Alignment.center,
child: Text("Hello"),
),
),
Container(
height: 50,
width: double.maxFinite,
decoration: BoxDecoration(
color: Colors.deepOrange,
borderRadius: BorderRadius.vertical(top: Radius.circular(20.0))
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(icon: Icon(Icons.arrow_forward), onPressed: (){},),
IconButton(icon: Icon(Icons.arrow_downward), onPressed: (){},),
IconButton(icon: Icon(Icons.arrow_left), onPressed: (){},),
IconButton(icon: Icon(Icons.arrow_upward), onPressed: (){},),
],
),
)
],
),
);
If you want to make a scrollable item/listview in the body section and want a fixed bottom container you can follow this code given below :
important note : Make sure wrap the listview with Expanded
import 'package:flutter/material.dart';
class ShoppingCart extends StatelessWidget {
#override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.grey[200],
appBar: AppBar(
backgroundColor: Colors.white,
leading: IconButton(
icon: Icon(Icons.arrow_back, color: Colors.black),
),
actions: <Widget>[
GestureDetector(
onTap: () {
//your code
},
child: Padding(
padding: const EdgeInsets.only(right: 15.0),
child: Icon(
Icons.delete_outline_sharp,
color: Colors.black,
size: 30,
),
)),
//Add more icon here
],
elevation: 0,
centerTitle: false,
title:
Text("Shopping Cart", style: TextStyle(color: Colors.black))),
body: Column(
children: [
Expanded(
child: ListView.builder(
itemCount: shoppingCartItems.length,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(
top: 15.0, left: 12.0, right: 12.0),
child: Container(
decoration: BoxDecoration(
// color: Color(0xffF3F3F3),
color: Colors.red,
shape: BoxShape.rectangle,
borderRadius:
BorderRadius.all(Radius.circular(10.0))),
height: 120,
width: 360,
),
);
},
),
),
Container(
height: 150,
width: double.maxFinite,
decoration: BoxDecoration(
color: Colors.deepOrange[200],
borderRadius:
BorderRadius.vertical(top: Radius.circular(20.0))),
)
],
));
}
}
Update :
This is built in now. You can use bottomNavigationBar and customize is as below :
bottomNavigationBar: BottomAppBar(
child: Container(
height: //set your height here
width: double.maxFinite, //set your width here
decoration: BoxDecoration(
color: Colors.orange,
borderRadius: BorderRadius.vertical(top: Radius.circular(20.0))
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(icon: Icon(Icons.arrow_forward), onPressed: (){
//on Presses functionaluty goes here
},),
//add as many tabs as you want here
],
),
),
),
bottomNavigationBar: BottomAppBar(
child: Container(
height: 50.0,
width: double.maxFinite,
decoration: BoxDecoration(
color: Colors.deepOrange,
borderRadius: BorderRadius.vertical(top: Radius.circular(20.0))
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
IconButton(icon: Icon(Icons.arrow_forward), onPressed: (){},),
IconButton(icon: Icon(Icons.arrow_downward), onPressed: (){},),
IconButton(icon: Icon(Icons.arrow_left), onPressed: (){},),
IconButton(icon: Icon(Icons.arrow_upward), onPressed: (){},),
],
),
),
),

How to implement a bottom navigation drawer in Flutter

I'm trying to implement a bottom navigation drawer, similar to the one used in the Reply Material Study, that is an extension of the bottom app bar, and opened and closed via an icon button in the bottom app bar.
I've tried bottom sheets, but that replaces, or hovers on top of, the bottom app bar. I want it to look like the one in the screenshot where the bottom app bar stays on the screen and the bottom navigation drawer slides up when the "menu" button is tapped.
The Material Design site shows this as a component, but doesn't link off to anywhere showing how to implement it in Flutter.
I quickly made it, but you are going to have to implement active page text/icon colors to the listview. Also, the full code is here if you want to copy from the gist.
class ScreenOne extends StatefulWidget {
#override
_ScreenOneState createState() => _ScreenOneState();
}
class _ScreenOneState extends State<ScreenOne> {
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Reply demo"),
),
bottomNavigationBar: BottomAppBar(
elevation: 0,
color: Color(0xff344955),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
height: 56.0,
child: Row(children: <Widget>[
IconButton(
onPressed: showMenu,
icon: Icon(Icons.menu),
color: Colors.white,
),
Spacer(),
IconButton(
onPressed: () {},
icon: Icon(Icons.add),
color: Colors.white,
)
]),
),
),
);
}
showMenu() {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
color: Color(0xff232f34),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
height: 36,
),
SizedBox(
height: (56 * 6).toDouble(),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
color: Color(0xff344955),
),
child: Stack(
alignment: Alignment(0, 0),
overflow: Overflow.visible,
children: <Widget>[
Positioned(
top: -36,
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(50)),
border: Border.all(
color: Color(0xff232f34), width: 10)),
child: Center(
child: ClipOval(
child: Image.network(
"https://i.stack.imgur.com/S11YG.jpg?s=64&g=1",
fit: BoxFit.cover,
height: 36,
width: 36,
),
),
),
),
),
Positioned(
child: ListView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
ListTile(
title: Text(
"Inbox",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.inbox,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Starred",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.star_border,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Sent",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.send,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Trash",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.delete_outline,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Spam",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.error,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Drafts",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.mail_outline,
color: Colors.white,
),
onTap: () {},
),
],
),
)
],
))),
Container(
height: 56,
color: Color(0xff4a6572),
)
],
),
);
});
}
}
You can use BottomSheet . (Thanks to westdabestdb)
Working on flutter_gallery demo app:
class ModalBottomSheetDemo extends StatelessWidget {
static const String routeName = '/material/modal-bottom-sheet';
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Modal bottom sheet'),
actions: <Widget>[MaterialDemoDocumentationButton(routeName)],
),
body: Center(
child: RaisedButton(
child: const Text('SHOW BOTTOM SHEET'),
onPressed: () {
showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text('This is the modal bottom sheet. Tap anywhere to dismiss.',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 24.0
)
)
)
);
});
}
)
)
);
}
}
Building up on westdabestdb's answer and this article:
If you want a bottom navigation drawer that is not blocking, with rounded corners and that is not depending on a black background, try this:
class GoogleMapsHomeUI extends StatelessWidget {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
#override
Widget build(BuildContext context) {
showBottomDrawer();
return Scaffold(
key: scaffoldKey, // use the key to reference the Scaffold from outside
... the rest of your background Scaffold
);
}
void showBottomDrawer() {
// the next line is needed, because the Scaffold needs to be finished before this function continues.
WidgetsBinding.instance.addPostFrameCallback((_) {
PersistentBottomSheetController? bottomSheetController = scaffoldKey.currentState?.showBottomSheet((BuildContext context) {
return Container(
height: 300,
decoration: BoxDecoration(
borderRadius: BorderRadius.only( // makes the round corners
topLeft: Radius.circular(20.0),
topRight: Radius.circular(20.0),
),
color: Color(0xff232f34),
),
child: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Container(
height: 36,
),
SizedBox(
height: (56 * 6).toDouble(),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16.0),
topRight: Radius.circular(16.0),
),
color: Color(0xff344955),
),
child: Stack(
alignment: Alignment(0, 0),
children: <Widget>[
Positioned(
top: -36,
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.all(Radius.circular(50)),
border: Border.all(
color: Color(0xff232f34), width: 10)),
child: Center(
child: ClipOval(
child: Image.network(
"https://i.stack.imgur.com/S11YG.jpg?s=64&g=1",
fit: BoxFit.cover,
height: 36,
width: 36,
),
),
),
),
),
Positioned(
child: ListView(
physics: NeverScrollableScrollPhysics(),
children: <Widget>[
ListTile(
title: Text(
"Inbox",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.inbox,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Starred",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.star_border,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Sent",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.send,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Trash",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.delete_outline,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Spam",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.error,
color: Colors.white,
),
onTap: () {},
),
ListTile(
title: Text(
"Drafts",
style: TextStyle(color: Colors.white),
),
leading: Icon(
Icons.mail_outline,
color: Colors.white,
),
onTap: () {},
),
],
),
)
],
))),
Container(
height: 56,
color: Color(0xff4a6572),
)
],
),
),
),
); // Container
},
backgroundColor: Colors.black,
elevation: 5,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.only(topLeft: Radius.circular(15.0), topRight: Radius.circular(15.0)),
), clipBehavior: null,
enableDrag: true,
);
result (I'm not finished with the background yet, but you can interact with the background, while the drawer is open):