[Flutter] DataTable를 사용하여 데이터 테이블 그리기
다음 예에서는 3개의 열 레이블과 3개의 행이 있는 간단한 DataTable을 정의합니다.
main.dart
import 'package:flutter/material.dart';void main() { runApp(MyApp());}class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState();}class _MyAppState extends State<MyApp> { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Flutter Tutorial - DataTable'), ), body: ListView(children: <Widget>[ Center( child: Text( 'Students', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold), )), DataTable( columns: [ DataColumn(label: Text('RollNo')), DataColumn(label: Text('Name')), DataColumn(label: Text('Class')), ], rows: [ DataRow(cells: [ DataCell(Text('1')), DataCell(Text('Arya')), DataCell(Text('6')), ]), DataRow(cells: [ DataCell(Text('12')), DataCell(Text('John')), DataCell(Text('9')), ]), DataRow(cells: [ DataCell(Text('42')), DataCell(Text('Tony')), DataCell(Text('8')), ]), ], ), ])), ); }} |
이 Flutter 애플리케이션을 실행하면 아래와 같이 UI에 DataTable이 표시됩니다.
댓글
댓글 쓰기