-1

我正在使用一些代码,但 FLutter 表没有以正确的方式显示数据,它以某种方式与数据重叠。

Table(
    defaultColumnWidth: FlexColumnWidth(1.0),
    defaultVerticalAlignment: TableCellVerticalAlignment.middle,
    border: TableBorder.all(), // Allows to add a border decoration around your table
    children: const [
        TableRow(children :[
            Text('Year'),
            Text('Lang'),
            Text('Author'),
        ]),
        TableRow(children :[
            Text('1990'),
            Text('Eng'),
            Text('ASD'),
        ]),
    ]
),

在此处输入图像描述

4

1 回答 1

0

按照这个:

import 'package:flutter/material.dart';  
  
void main() {runApp(MyApp());}  
  
class MyApp extends StatefulWidget {  
  @override  
  _TableExample createState() => _TableExample();  
}  
  
class _TableExample extends State<MyApp> {  
  @override  
  Widget build(BuildContext context) {  
    return MaterialApp(  
      home: Scaffold(  
          appBar: AppBar(  
            title: Text('Flutter Table Example'),  
          ),  
          body: Center(  
              child: Column(children: <Widget>[  
                Container(  
                  margin: EdgeInsets.all(20),  
                  child: Table(  
                    defaultColumnWidth: FixedColumnWidth(120.0),  
                    border: TableBorder.all(  
                        color: Colors.black,  
                        style: BorderStyle.solid,  
                        width: 2),  
                    children: [  
                      TableRow( children: [  
                        Column(children:[Text('Website', style: TextStyle(fontSize: 20.0))]),  
                        Column(children:[Text('Tutorial', style: TextStyle(fontSize: 20.0))]),  
                        Column(children:[Text('Review', style: TextStyle(fontSize: 20.0))]),  
                      ]),  
                      TableRow( children: [  
                        Column(children:[Text('Javatpoint')]),  
                        Column(children:[Text('Flutter')]),  
                        Column(children:[Text('5*')]),  
                      ]),  
                      TableRow( children: [  
                        Column(children:[Text('Javatpoint')]),  
                        Column(children:[Text('MySQL')]),  
                        Column(children:[Text('5*')]),  
                      ]),  
                      TableRow( children: [  
                        Column(children:[Text('Javatpoint')]),  
                        Column(children:[Text('ReactJS')]),  
                        Column(children:[Text('5*')]),  
                      ]),  
                    ],  
                  ),  
                ),  
              ])  
          )),  
    );  
  }  
}  
于 2021-12-14T09:14:49.983 回答