I need to show my data's like as above image in flutter. I don't have idea about ,So anyone can help me to solve the problem.
Asked
Active
Viewed 141 times
0
-
Take a look at [DataTable](https://api.flutter.dev/flutter/material/DataTable-class.html) in Flutter's API – raw-chicken Mar 16 '23 at 06:49
-
you can also use [PaginatedDataTable](https://api.flutter.dev/flutter/material/PaginatedDataTable-class.html) widget in flutter – Munsif Ali Mar 16 '23 at 06:55
1 Answers
1
import 'package:flutter/material.dart';
// main method that runs the runApp.
void main() => runApp(SimpleDataTable());
class SimpleDataTable extends StatelessWidget{
@override
Widget build(BuildContext context) {
return MaterialApp(
// MaterialApp with debugShowCheckedModeBanner false and home
debugShowCheckedModeBanner: false,
theme: ThemeData.light(),
home: Scaffold(
// Scaffold with appbar ans body.
appBar: AppBar(
title: Text('Simple Data Table'),
),
body:
SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
// Datatable widget that have the property columns and rows.
columns: [
// Set the name of the column
DataColumn(label: Text('ID'),),
DataColumn(label: Text('Name'),),
DataColumn(label: Text('LastName'),),
DataColumn(label: Text('Age'),),
],
rows:[
// Set the values to the columns
DataRow(cells: [
DataCell(Text("1")),
DataCell(Text("Alex")),
DataCell(Text("Anderson")),
DataCell(Text("18")),
]),
DataRow(cells: [
DataCell(Text("2")),
DataCell(Text("John")),
DataCell(Text("Anderson")),
DataCell(Text("24")),
]),
]
),
),
),
);
}
}
- Body Contain SingleChildScrollView used to Scroll Horizontally and Avoid Overflow due to Mobile with Low Screen Width.
- SingleChildScrollView takes Single Child DataTable which takes Columns and Rows.
- Columns represented in DataColumn that take a Label.
- Rows represented in DataRow take Cells followed by DataCell that takes any Widget representing each Column Value of the Row.

Javatar
- 131
- 6
-
thanks buddy, I need to call data from api ,how can i achieve that? – Sakthivel k Mar 16 '23 at 10:03
-
-
see it bro. https://stackoverflow.com/questions/75729257/which-is-the-best-way-of-api-call-in-flutter/75729314#75729314 – Javatar Mar 16 '23 at 11:38