Flutter15.Table

ex:

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(
  home: HomePage(),
));

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Table(
          columnWidths: const <int, TableColumnWidth>{
            0: FixedColumnWidth(50.0),
            1: FixedColumnWidth(100.0),
            2: FixedColumnWidth(50.0),
            3: FixedColumnWidth(50.0),
          },
          border: TableBorder.all(
            color: Colors.blue,
            width: 2.0,
          ),
          children: const <TableRow>[
            TableRow(children: [
              Text('头像'),
              Text('姓名'),
              Text('年龄'),
              Text('身高'),
            ]),
            TableRow(children: [
              Icon(Icons.account_circle),
              Text('LiLei'),
              Text('21'),
              Text('174cm'),
            ]),
            TableRow(children: [
              Icon(Icons.account_circle),
              Text('HanMeimei'),
              Text('21'),
              Text('174cm'),
            ]),
            TableRow(children: [
              Icon(Icons.account_circle),
              Text('Lily'),
              Text('21'),
              Text('174cm'),
            ]),
          ],
        ),
      ),
    );
  }
}

输出:

猜你喜欢

转载自blog.csdn.net/augfun/article/details/106976895
今日推荐