Repository navigation
Frustrations with DataTable #151005
Description
There was a lot of pagination back in the good old days, but modern apps have transitioned to use infinite scrolling.
ListTile
Flutter list tiles are fantastic—instead of just a single class, the material library also supplies AboutListTile, CheckboxListTile, RadioListTile, and SwitchListTile, each with their own onTap configuration.
DataTable
Conversely, it's impossible to set an onTap callback for a DataRow.
There's an onLongPress option, but the only way to have a callback for a tap is to use onSelectChanged, which automatically adds a column of checkboxes. And there's no option to wrap with an InkWell or GestureDetector, since DataRow isn't a widget.
I'm currently working with a nonprofit to make a Flutter app. My friend @ChaAbby went to the effort of implementing a DataTable, only to discover that its performance drops off quickly as it grows in length. We'll have to either scrap it and switch to a CustomScrollView, or use the paginated version and work with a user interface that belongs in the previous decade.
Every widget in the Material library applies to a Material 3 component, with one exception.
If we end up implementing something along the lines of #143499 for older widgets, it should also apply to DataTable.

Activity
Piinks commentedon Jul 3, 2024
@nate-thegrate is there a specific feature or bug that this issue is covering? I am not sure what PR we could raise to resolve it as it is. :)
This is because the DataTable is not designed for scrolling. It is a box widget as opposed to a sliver, and will lay out all of its content rather than optimizing for what is currently visible. The TableView widget in the two_dimensional_scrollables package could help. It can scroll in 2D, but you can also use it to build a lazy 1D scrolling table.
What is the exception? There are multiple material widgets that existed before M3 and have not been updated since they are not part of the M3 spec.
nate-thegrate commentedon Jul 3, 2024
At one point, I decided to read through the full widget index, and my conclusion was that
DataTablewas the only class that does not apply to either the Material or Cupertino design systems.This issue was intended more along the lines of the dart-lang request template, i.e. describing a problem without any proposal for a solution. Perhaps I'll be able to refer to it a few months down the line.
Thanks for taking the time to read it over; I'm good with marking this as P3 if that's good with you.
Piinks commentedon Jul 3, 2024
It is not. DataTable implements the original Material Design.
I am still not sure what the problem is though. Can you explain?
nate-thegrate commentedon Jul 3, 2024
That's a good point; I apologize for misspeaking earlier. I think it would be more accurate to say "out of all the widgets in the Material library, DataTable is, by a significant margin, the most different from any Material 3 component."
My problems with DataTable are entirely subjective: on multiple occasions I've tried adding one to an app and found the lack of customizability very frustrating.
Instead of a border, columns are separated using 56-pixel-wide blank space by default. That, combined with its lack of scrolling optimization, makes it stick out to me as a widget that isn't suitable for mobile apps.
Thanks for letting me know about the TableView widget; it appears to address all of DataTable's shortcomings, so I'm excited to learn more about it.
At this point, it's clear to me that a GitHub issue was not the appropriate place to vent these frustrations; I probably should have shared this on Reddit or Discord instead.
nate-thegrate commentedon Jul 5, 2024
Just thought of something!
Update `DataTable` documentation (#151356)
Update `DataTable` documentation (flutter#151356)
github-actions commentedon Jul 22, 2024
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.