Skip to content

Commit fc7bbe3

Browse files
committed
GFDrawer with gradient color backgroung completed
1 parent dce6054 commit fc7bbe3

2 files changed

Lines changed: 27 additions & 5 deletions

File tree

example/lib/main.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,19 @@ class _MyHomePageState extends State<MyHomePage> {
7373
Widget build(BuildContext context) {
7474
return Scaffold(
7575
drawer: GFDrawer(
76+
colorFilter: new ColorFilter.mode(Colors.black.withOpacity(0.6), BlendMode.darken),
7677
backgroundImage: NetworkImage("https://cdn.pixabay.com/photo/2017/12/03/18/04/christmas-balls-2995437_960_720.jpg"),
78+
gradient: LinearGradient(
79+
begin: Alignment.topRight,
80+
end: Alignment.bottomLeft,
81+
stops: [0.1, 0.5, 0.7, 0.9],
82+
colors: [
83+
Colors.teal[800],
84+
Colors.teal[600],
85+
Colors.teal[400],
86+
Colors.teal[200],
87+
],
88+
),
7789
child: ListView(
7890
padding: EdgeInsets.zero,
7991
children: <Widget>[

lib/components/drawer/gf_drawer.dart

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ class GFDrawer extends StatelessWidget {
130130
this.elevation = 16.0,
131131
this.child,
132132
this.semanticLabel,
133-
this.backgroundImage
133+
this.backgroundImage,
134+
this.colorFilter,
135+
this.gradient
134136
}) : assert(elevation != null && elevation >= 0.0),
135137
super(key: key);
136138

@@ -161,8 +163,15 @@ class GFDrawer extends StatelessWidget {
161163
/// value is used.
162164
final String semanticLabel;
163165

166+
/// Background image can be added to the [GFDrawer].
164167
final ImageProvider backgroundImage;
165168

169+
/// A composited layer that applies a color filter to its children.
170+
final ColorFilter colorFilter;
171+
172+
///
173+
final Gradient gradient;
174+
166175
@override
167176
Widget build(BuildContext context) {
168177
assert(debugCheckHasMaterialLocalizations(context));
@@ -186,12 +195,13 @@ class GFDrawer extends StatelessWidget {
186195
elevation: elevation,
187196
child: Container(
188197
decoration: new BoxDecoration(
189-
image: new DecorationImage(
198+
color: Colors.teal,
199+
gradient: gradient,
200+
image: backgroundImage != null ? new DecorationImage(
190201
image: backgroundImage,
191202
fit: BoxFit.cover,
192-
colorFilter: new ColorFilter.mode(
193-
Colors.black.withOpacity(0.65), BlendMode.darken),
194-
),
203+
colorFilter: colorFilter,
204+
) : null,
195205
),
196206
child: child
197207
),

0 commit comments

Comments
 (0)