card.dart 943 Bytes
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
const EdgeInsets _kCardMargins = const EdgeInsets.all(4.0);
10

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

21
  /// The widget below this widget in the tree.
22
  final Widget child;
23 24

  /// The color of material used for this card.
25 26
  final Color color;

27
  @override
28
  Widget build(BuildContext context) {
29
    return new Container(
30
      margin: _kCardMargins,
31 32 33
      child: new Material(
        color: color,
        type: MaterialType.card,
34
        elevation: 2,
35
        child: child
36 37 38 39
      )
    );
  }
}