Skip to content

Conversation

nero-angela
Copy link
Contributor

@nero-angela nero-angela commented Aug 9, 2020

Description

Adds a rowSpacing property to the Table class.

before add rowSpacing after add rowSpacing="10"

Related Issues

Fixes #52248

Tests

I added the following tests:

  • Tests to ensure that additional space is added in between each TableRow.

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

  • No, no existing tests failed, so this is not a breaking change.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 9, 2020
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This kind of reminds me of #16957, which was decided not to be added to the framework.
I could see how supporting row spacing would logically call on support for Column spacing as well.
If we follow the recommendation in the Row/Column spacing discussion in #16957, maybe adding an empty TableRow in between the other TableRows is a better approach? Not sure.

@nero-angela
Copy link
Contributor Author

nero-angela commented Aug 11, 2020

@Piinks Unlike Row / Column, Table can only receive TableRow as a child, and each TableRow must have the same number of columns. So I can add space like the below code.

TableRow(
  children: <Widget>[
    Container(child: Text('1'), height: 100),
    Container(child: Text('2'), height: 100),
    Container(child: Text('3'), height: 100),
  ],
),
TableRow(
  children: <Widget>[
    SizedBox(height: 10),
    SizedBox(height: 10),
    SizedBox(height: 10),
  ],
),
TableRow(
  children: <Widget>[
    Container(child: Text('4'), height: 100),
    Container(child: Text('5'), height: 100),
    Container(child: Text('6'), height: 100),
  ],
),

There may be other ways I don't know, Wrap cannot be used and SizedBox or Padding corresponding to the number of columns must be implemented.

And I think we should compare the Table with the GridView, not the Row/Column.
In the GridView, there are crossAxisSpacing and mainAxisSpacing properties. In fact, these properties can also be implemented a variety of ways.

In addition, the Table is less complex than the Row/Column. So I think it's okay to add rowSpacing to Table, But If you don't agree with it, I would close this PR.

For reference, in the widget of the week introduces the Table like the below.

If you have a grid of widgets that you don't want to scroll?
That's what Table is for!

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also not convinced that adding this is a good idea. If we'd do this, we'd probably also have to provide a way to add padding between the cells in one row. Just having rowPadding seems odd. It's also not terribly difficult to get this spacing without extra framework support:

          TableRow spacer = TableRow(
            children: <Widget>[
              SizedBox(height: 10),
              SizedBox(height: 10),
              SizedBox(height: 10),
            ],
          );

          Table(
            children: [
              TableRow(
                children: <Widget>[
                  Container(child: Text('1'), height: 100),
                  Container(child: Text('2'), height: 100),
                  Container(child: Text('3'), height: 100),
                ],
              ),
              spacer,
              TableRow(
                children: <Widget>[
                  Container(child: Text('4'), height: 100),
                  Container(child: Text('5'), height: 100),
                  Container(child: Text('6'), height: 100),
                ],
              ),
              spacer,
              TableRow(
                children: <Widget>[
                  Container(child: Text('7'), height: 100),
                  Container(child: Text('8'), height: 100),
                  Container(child: Text('9'), height: 100),
                ],
              ),
            ],
          ),

// then, lay out each row
double rowTop = 0.0;
for (int y = 0; y < rows; y += 1) {
if (y != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably, this also needs changes to the intrinsics methods.

@nero-angela
Copy link
Contributor Author

nero-angela commented Aug 26, 2020

If adding rowSpacing isn't a good idea, it might be better to close this PR and the related issue. 🙏

@goderbauer goderbauer closed this Aug 26, 2020
@nero-angela nero-angela deleted the row_spacing branch August 28, 2020 03:49
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Padding inside Table

4 participants