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

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

  final Widget child;
  final Color color;

20
  Widget build(BuildContext context) {
21
    return new Container(
22
      margin: _kCardMargins,
23 24 25
      child: new Material(
        color: color,
        type: MaterialType.card,
26
        elevation: 2,
27
        child: child
28 29 30 31
      )
    );
  }
}