scrollable_table_view 0.0.4 scrollable_table_view: ^0.0.4 copied to clipboard
This is a multi axis scrollable data table, that allows you to scroll on both the vertical and horizontal axis, with the header remaining static on the vertical axis.
import 'package:example/model.dart';
import 'package:flutter/material.dart';
import 'package:scrollable_table_view/scrollable_table_view.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Scrollable Table View Example'),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
var columns = products.first.keys.toList();
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: ScrollableTableView(
columns: columns.map((column) {
return TableViewColumn(
label: column,
);
}).toList(),
rows: products.map((product) {
return TableViewRow(
height: 60,
cells: columns.map((column) {
return TableViewCell(
child: Text(product[column] ?? ""),
);
}).toList(),
);
}).toList(),
),
);
}
}