Skip to content

Commit dce6054

Browse files
committed
GFdrawer with background image completed
1 parent d28d80a commit dce6054

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

example/lib/main.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
7373
Widget build(BuildContext context) {
7474
return Scaffold(
7575
drawer: GFDrawer(
76+
backgroundImage: NetworkImage("https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg"),
7677
child: ListView(
7778
padding: EdgeInsets.zero,
7879
children: <Widget>[

lib/components/drawer/gf_drawer.dart

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ const Duration _kBaseSettleDuration = Duration(milliseconds: 246);
117117
/// shown.
118118
/// * [Scaffold.of], to obtain the current [ScaffoldState], which manages the
119119
/// display and animation of the drawer.
120-
/// * [ScaffoldState.openGFDrawer], which displays its [GFDrawer], if any.
121-
/// * <https://material.io/design/components/navigation-drawer.html>
120+
/// * [ScaffoldState.openGFDrawer], which displays its [GFDrawer].
121+
///
122122
class GFDrawer extends StatelessWidget {
123123
/// Creates a material design drawer.
124124
///
@@ -130,6 +130,7 @@ class GFDrawer extends StatelessWidget {
130130
this.elevation = 16.0,
131131
this.child,
132132
this.semanticLabel,
133+
this.backgroundImage
133134
}) : assert(elevation != null && elevation >= 0.0),
134135
super(key: key);
135136

@@ -160,6 +161,8 @@ class GFDrawer extends StatelessWidget {
160161
/// value is used.
161162
final String semanticLabel;
162163

164+
final ImageProvider backgroundImage;
165+
163166
@override
164167
Widget build(BuildContext context) {
165168
assert(debugCheckHasMaterialLocalizations(context));
@@ -181,7 +184,17 @@ class GFDrawer extends StatelessWidget {
181184
constraints: const BoxConstraints.expand(width: _kWidth),
182185
child: Material(
183186
elevation: elevation,
184-
child: child,
187+
child: Container(
188+
decoration: new BoxDecoration(
189+
image: new DecorationImage(
190+
image: backgroundImage,
191+
fit: BoxFit.cover,
192+
colorFilter: new ColorFilter.mode(
193+
Colors.black.withOpacity(0.65), BlendMode.darken),
194+
),
195+
),
196+
child: child
197+
),
185198
),
186199
),
187200
);

0 commit comments

Comments
 (0)