zoukankan      html  css  js  c++  java
  • flutter Card卡片列表组件

    一个 Material Design 卡片。拥有一个圆角和阴影

    import 'package:flutter/material.dart';
    import './model/post.dart';
    
    class CardDemo extends StatefulWidget {
      @override
      _CardDemoState createState() => _CardDemoState();
    }
    
    class _CardDemoState extends State<CardDemo> {
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: Text('CardDemo'),
            elevation: 0.0,
          ),
          body: Container(
            padding: EdgeInsets.all(16.0),
            child: ListView(
              children: posts.map((post) {
                return Card(
                  child: Column(
                    children: <Widget>[
                      AspectRatio(
                        aspectRatio: 16/9,
                        child: ClipRRect(
                          borderRadius: BorderRadius.only(
                            topLeft: Radius.circular(4.0),
                            topRight: Radius.circular(4.0),
                          ),
                          child: Image.network(
                            post.imageUrl,
                            fit: BoxFit.cover,
                          ),
                        ),
                      ),
                      ListTile(
                        leading: CircleAvatar(
                          backgroundImage: NetworkImage(post.imageUrl),
                        ),
                        title: Text(post.title),
                        subtitle: Text(post.author),
                      ),
                      Container(
                        padding: EdgeInsets.all(16.0),
                        child: Text(post.description, maxLines: 2, overflow: TextOverflow.ellipsis,),
                      ),
                      ButtonTheme.bar(
                        child: ButtonBar(
                          children: <Widget>[
                            FlatButton(
                              child: Text('Like'.toUpperCase()),
                              onPressed: () {},
                            ),
                            FlatButton(
                              child: Text('Read'.toUpperCase()),
                              onPressed: () {},
                            ),
                          ],
                        ),
                      ),
                    ],
                  ),
                );
              }).toList(),
            ),
          )
        );
      }
    }

    效果:

  • 相关阅读:
    WEB测试用例(十五)
    WEB测试用例(十二)
    WEB测试用例(九)
    WEB测试用例(六)
    WEB测试用例(四)
    WEB测试用例(一)
    WEB测试方法(十一)
    WEB测试方法(十)
    Python 知识要点:对象的 init 和 del 方法
    Python 知识要点:类 和 对象
  • 原文地址:https://www.cnblogs.com/loaderman/p/11342888.html
Copyright © 2011-2022 走看看