flutter布局-卡片布局Card

卡片布局默认是撑满整个外部容器的,如果你想设置卡片的宽高,需要在外部容器就进行制定。

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var card = new Card(
        child: Column(
            children: [
                ListTile(
                    title: new Text('title', style: TextStyle(fontWeight: FontWeight.w500),),
                    subtitle: new Text('subtitle'),
                    leading: new Icon(Icons.account_box, color: Colors.blue,),
                ),
                new Divider(),
                ListTile(
                    title: new Text('title'),
                    subtitle: new Text('subtitle'),
                    leading: new Icon(Icons.account_box),
                ),
                new Divider(),
                ListTile(
                    title: new Text('title'),
                    subtitle: new Text('subtitle'),
                    leading: new Icon(Icons.account_box),
                )
            ],
        ),
    );
    return MaterialApp(
        title: 'flutter demo',
        home: Scaffold(
          appBar: new AppBar(
            title: new Text('卡片布局Card'),
          ),
          body: Center(child: card),
        ));
  }
}
View Code

posted @ 2021-02-01 10:32  江离白芷  阅读(1000)  评论(0)    收藏  举报