card.dart 1.06 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 'material.dart';
8 9 10

/// A material design card
///
11 12 13 14 15
/// See also:
///
///  * [Dialog]
///  * [showDialog]
///  * <https://www.google.com/design/spec/components/cards.html>
16
class Card extends StatelessWidget {
17 18 19
  /// Creates a material design card.
  const Card({
    Key key,
20 21 22
    this.color,
    this.elevation: 2,
    this.child
23
  }) : super(key: key);
24

25
  /// The widget below this widget in the tree.
26
  final Widget child;
27 28

  /// The color of material used for this card.
29 30
  final Color color;

31 32 33
  /// The following elevations have defined shadows: 1, 2, 3, 4, 6, 8, 9, 12, 16, 24
  final int elevation;

34
  @override
35
  Widget build(BuildContext context) {
36
    return new Container(
37
      margin: const EdgeInsets.all(4.0),
38 39 40
      child: new Material(
        color: color,
        type: MaterialType.card,
41
        elevation: elevation,
42
        child: child
43 44 45 46
      )
    );
  }
}