Skip to content

Instantly share code, notes, and snippets.

@cerberodev
Last active August 1, 2024 03:59
Show Gist options
  • Save cerberodev/12f0932e47a0fed9b7faff66548c4522 to your computer and use it in GitHub Desktop.
Save cerberodev/12f0932e47a0fed9b7faff66548c4522 to your computer and use it in GitHub Desktop.
Widget DataTable with border radius.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: TableData(),
);
}
}
class TableData extends StatelessWidget {
const TableData({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Holi DataTable'),
),
body: Container(
color: Colors.pink[100],
child: Center(
child: Column(children: [
SizedBox(
height: 100,
width: 100,
),
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
width: 350,
height: 180,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
//boxShadow: [
// BoxShadow(
// color: Colors.black
// .withOpacity(1), // changes position of shadow
// ),
//],
),
child: DataTable(
columnSpacing: 90,
dataRowHeight: 30,
horizontalMargin: 15,
headingRowColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
return Color(0xFFF8F9FA);
}),
columns: [
DataColumn(label: Text('Productos')),
DataColumn(label: Text('Cantidad'))
],
rows: [
DataRow(
cells: [
DataCell(Text('Champan Baron B')),
DataCell(Text('2')),
],
),
DataRow(
cells: [
DataCell(Text('Cerveza Miller')),
DataCell(Text('4')),
],
),
DataRow(
cells: [
DataCell(Text('Cerveza Patagonia')),
DataCell(Text('4')),
],
),
DataRow(
cells: [
DataCell(Text('Cerveza Imperial')),
DataCell(Text('2')),
],
),
],
),
),
),
]),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment