I wonder if i can use background image instead of color in flutter app drawer header, Is there any way?
I am able to customize he color but i am wonder if is there any property to alter the color with custom image.
I wonder if i can use background image instead of color in flutter app drawer header, Is there any way?
I am able to customize he color but i am wonder if is there any property to alter the color with custom image.
You can use decoration in DrawerHeader to set image as drawer header
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: Text('some text')),
drawer: Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
image: DecorationImage(
image: AssetImage("assets/gold.jpg"),
fit: BoxFit.cover)
),
),
ListTile(
title: Text('Item 1'),
onTap: () {
Navigator.pop(context);
},
),
ListTile(
title: Text('Item 2'),
onTap: () {
Navigator.pop(context);
},
),
],
),
),
);
also see this link
Declare a container inside it. this worked for me :
Drawer(
elevation: 5,
child: Container(
width: 200,
height: 100,
decoration: BoxDecoration(
image: new DecorationImage(
image: AssetImage("lib/assets/bookcover.jpg"),
fit: BoxFit.cover,
),
),
© 2022 - 2024 — McMap. All rights reserved.