Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frustrations with DataTable #151005

Closed
nate-thegrate opened this issue Jun 28, 2024 · 6 comments · Fixed by #151356
Closed

Frustrations with DataTable #151005

nate-thegrate opened this issue Jun 28, 2024 · 6 comments · Fixed by #151356
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. perf: speed Performance issues related to (mostly rendering) speed team-design Owned by Design Languages team

Comments

@nate-thegrate
Copy link
Member

google search pages

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.

@nate-thegrate nate-thegrate added f: material design flutter/packages/flutter/material repository. c: performance Relates to speed or footprint issues (see "perf:" labels) f: scrolling Viewports, list views, slivers, etc. perf: speed Performance issues related to (mostly rendering) speed team-design Owned by Design Languages team labels Jun 28, 2024
@Piinks
Copy link
Contributor

Piinks commented 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. :)

implementing a DataTable, only to discover that its performance drops off quickly as it grows in length.

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.

Every widget in the Material library applies to a Material 3 component, with one exception.

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
Copy link
Member Author

At one point, I decided to read through the full widget index, and my conclusion was that DataTable was 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.

@nate-thegrate nate-thegrate added P3 Issues that are less important to the Flutter project triaged-design Triaged by Design Languages team labels Jul 3, 2024
@Piinks
Copy link
Contributor

Piinks commented Jul 3, 2024

and my conclusion was that DataTable was the only class that does not apply to either the Material or Cupertino design systems.

It is not. DataTable implements the original Material Design.

describing a problem

I am still not sure what the problem is though. Can you explain?

@Piinks Piinks removed P3 Issues that are less important to the Flutter project triaged-design Triaged by Design Languages team labels Jul 3, 2024
@nate-thegrate
Copy link
Member Author

DataTable implements the original Material Design.

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
Copy link
Member Author

I am not sure what PR we could raise to resolve it as it is.

Just thought of something!

@nate-thegrate nate-thegrate reopened this Jul 5, 2024
auto-submit bot pushed a commit that referenced this issue Jul 8, 2024
This PR resolves [some problems I was having with `DataTable`](#151005), based on advice from the style guide:

> ### Answer your own questions straight away
> If you find yourself asking a question about our systems, please place whatever answer you subsequently discover into the documentation in the same place where you first looked for the answer. That way, the documentation will consist of answers to real questions, where people would look to find them.

The `DataTable` documentation now specifies that the widget is based on the Material 2 spec, and it offers a list of useful alternatives.

<br>

Additionally, an item in the "See also" section was updated to use a reliable Go link:

```diff
- ///  * <https://material.io/design/components/data-tables.html>
  ///  * <https://material.io/go/design-data-tables>
```
victorsanni pushed a commit to victorsanni/flutter that referenced this issue Jul 8, 2024
This PR resolves [some problems I was having with `DataTable`](flutter#151005), based on advice from the style guide:

> ### Answer your own questions straight away
> If you find yourself asking a question about our systems, please place whatever answer you subsequently discover into the documentation in the same place where you first looked for the answer. That way, the documentation will consist of answers to real questions, where people would look to find them.

The `DataTable` documentation now specifies that the widget is based on the Material 2 spec, and it offers a list of useful alternatives.

<br>

Additionally, an item in the "See also" section was updated to use a reliable Go link:

```diff
- ///  * <https://material.io/design/components/data-tables.html>
  ///  * <https://material.io/go/design-data-tables>
```
Copy link

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 -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 22, 2024
@nate-thegrate nate-thegrate removed the waiting for PR to land (fixed) A fix is in flight label Oct 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: performance Relates to speed or footprint issues (see "perf:" labels) f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. perf: speed Performance issues related to (mostly rendering) speed team-design Owned by Design Languages team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants