drawer_header.dart 1.95 KB
Newer Older
1 2 3 4
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'package:flutter/widgets.dart';
6

7
import 'debug.dart';
8
import 'theme.dart';
9

10 11
const double _kDrawerHeaderHeight = 140.0;

12 13 14 15 16 17 18
/// The top-most region of a material design drawer.
///
/// Part of the material design [Drawer].
///
/// Requires one of its ancestors to be a [Material] widget.
///
/// See also:
19
///
20 21 22
///  * [Drawer]
///  * [DrawerItem]
///  * <https://www.google.com/design/spec/patterns/navigation-drawer.html>
23
class DrawerHeader extends StatelessWidget {
24 25 26
  /// Creates a material design drawer header.
  ///
  /// Requires one of its ancestors to be a [Material] widget.
27
  const DrawerHeader({ Key key, this.child }) : super(key: key);
28

29
  /// The widget below this widget in the tree.
30
  final Widget child;
31

32
  @override
33
  Widget build(BuildContext context) {
34
    assert(debugCheckHasMaterial(context));
35
    final double statusBarHeight = MediaQuery.of(context).padding.top;
36
    return new Container(
37
      height: statusBarHeight + _kDrawerHeaderHeight,
38
      decoration: new BoxDecoration(
39 40
        // TODO(jackson): This class should usually render the user's
        // preferred banner image rather than a solid background
41
        backgroundColor: Theme.of(context).cardColor,
42 43 44 45 46 47 48
        border: const Border(
          bottom: const BorderSide(
            color: const Color(0xFFD1D9E1),
            width: 1.0
          )
        )
      ),
49 50
      padding: const EdgeInsets.only(bottom: 7.0),
      margin: const EdgeInsets.only(bottom: 8.0),
51 52 53 54
      child: new Column(
        children: <Widget>[
          new Flexible(child: new Container()),
          new Container(
55
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
56
            child: new DefaultTextStyle(
57
              style: Theme.of(context).textTheme.body2,
58 59
              child: child
            )
60
          )
61
        ]
62 63 64 65
      )
    );
  }
}