card.dart 888 Bytes
Newer Older
1 2 3 4 5 6 7
// 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.

import 'package:sky/widgets/basic.dart';
import 'package:sky/widgets/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>
class Card extends Component {
14
  Card({ Key key, this.child, this.color }) : super(key: key);
15 16 17 18 19 20

  final Widget child;
  final Color color;

  Widget build() {
    return new Container(
21
      margin: kCardMargins,
22 23 24 25 26 27 28 29 30 31 32 33 34
      child: new Material(
        color: color,
        type: MaterialType.card,
        level: 2,
        child: new ClipRRect(
          xRadius: edges[MaterialType.card],
          yRadius: edges[MaterialType.card],
          child: child
        )
      )
    );
  }
}