MIF_E31211879/lib/dashboard/tabel_IMT.dart

147 lines
4.8 KiB
Dart

import 'package:flutter/material.dart';
class TabelIMT extends StatelessWidget {
bool isDialogOpen = false;
void _showIMTTable(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) {
isDialogOpen = true; // Atur status dialog menjadi terbuka
return AlertDialog(
title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Tabel IMT',
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
IconButton(
icon: Icon(Icons.close),
onPressed: () {
Navigator.of(context).pop();
isDialogOpen =
false; // Setelah ditutup, atur status dialog menjadi tertutup
},
),
],
),
backgroundColor: Color.fromARGB(255, 250, 154, 0),
content: SingleChildScrollView(
child: Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.only(left: 1.0),
color: Colors.white,
child: DataTable(
columnSpacing: 16.0,
dataRowHeight: 80.0,
columns: <DataColumn>[
DataColumn(
label: Text(
'Klasifikasi',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'Keterangan',
style: TextStyle(fontWeight: FontWeight.bold),
),
),
DataColumn(
label: Text(
'IMT',
style: TextStyle(fontWeight: FontWeight.bold),
textAlign: TextAlign.center,
),
),
],
rows: <DataRow>[
DataRow(
cells: <DataCell>[
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Kurus',
style: TextStyle(fontWeight: FontWeight.bold),
),
)),
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text('Berat \nRingan'),
)),
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text('<17.0\n17.0-18.4'),
)),
],
),
DataRow(
cells: <DataCell>[
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Normal',
style: TextStyle(fontWeight: FontWeight.bold),
),
)),
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text(''),
)),
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text('18.5-25.0'),
)),
],
),
DataRow(
cells: <DataCell>[
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Gemuk',
style: TextStyle(fontWeight: FontWeight.bold),
),
)),
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text('Ringan \nBerat'),
)),
DataCell(Padding(
padding: EdgeInsets.all(8.0),
child: Text('25.1-27.0\n>27'),
)),
],
),
],
),
),
),
);
},
);
}
@override
Widget build(BuildContext context) {
return Center(
child: Column(
children: [
Visibility(
visible:
!isDialogOpen, // Tombol hanya terlihat jika dialog tidak terbuka
child: ElevatedButton(
onPressed: () {
_showIMTTable(context);
},
child: Text('Tampilkan Tabel IMT'),
),
),
],
),
);
}
}