Skip to content

Conversation

@TahaTesser
Copy link
Member

@TahaTesser TahaTesser commented Feb 23, 2024

fixes [DataTable] Unable to center the label of a DataColumn without side effects

Code sample

expand to view the code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MaterialApp(
        home: Material(
          child: DataTable(
            columns: <DataColumn>[
              DataColumn(
                headingRowAlignment: MainAxisAlignment.center,
                onSort: (int columnIndex, bool ascending) {},
                label: const Text('Header'),
              ),
            ],
            sortColumnIndex: 0,
            rows: const <DataRow>[
              DataRow(
                cells: <DataCell>[
                  DataCell(Center(child: Text('Data'))),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Center DataColumn.headingRowAlignment without sort arrow

Screenshot 2024-03-25 at 17 13 05

Center DataColumn.headingRowAlignment with sort arrow

Screenshot 2024-03-25 at 17 11 54

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Feb 23, 2024
@TahaTesser TahaTesser marked this pull request as ready for review February 23, 2024 11:32
@TahaTesser TahaTesser changed the title Add DataColumn.mainAxisAlignment for DataTable Add DataColumn. centerLabel for DataTable Feb 28, 2024
@TahaTesser TahaTesser changed the title Add DataColumn. centerLabel for DataTable Add DataColumn.centerLabel for DataTable Feb 28, 2024
@TahaTesser TahaTesser requested a review from Piinks February 28, 2024 12:14
@Naderfat

This comment was marked as off-topic.

@TahaTesser TahaTesser requested a review from Piinks March 18, 2024 12:44
@TahaTesser TahaTesser changed the title Add DataColumn.centerLabel for DataTable Add DataColumn.mainAxisAlignment for DataTable Mar 25, 2024
@TahaTesser
Copy link
Member Author

@Piinks
Added DataColumn.mainAxisAlignment with new docs and tests, please take a look.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh gosh I feel silly for not noticing this earlier. This should probably be crossAxisAlignment, technically. We are talking about the horizontal alignment of DataColumn, for which the main axis would technically be vertical.

Or we could call it headerMainAxisAlignment, since it only applies to the header rather than the whole column. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh gosh I feel silly for not noticing this earlier. This should probably be crossAxisAlignment, technically. We are talking about the horizontal alignment of DataColumn, for which the main axis would technically be vertical.

Great observation! I was focused on Row widget inside the DataColumn. I didn't consider what it means for the DataColumn with column in the name.

Or we could call it headerMainAxisAlignment, since it only applies to the header rather than the whole column. WDYT?

Sounds good to me. This could be consistent with other header properties if we do headingRowAlignment

this.headingRowColor,
this.headingRowHeight,
this.headingTextStyle,

I also added this to DataTableTheme.

Copy link
Contributor

Choose a reason for hiding this comment

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

Perfect!

@TahaTesser TahaTesser requested a review from Piinks March 28, 2024 13:27
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.

Flutter_LGTM

@TahaTesser TahaTesser changed the title Add DataColumn.mainAxisAlignment for DataTable Add DataColumn.headingRowAlignment for DataTable Apr 1, 2024
@TahaTesser TahaTesser added the autosubmit Merge PR when tree becomes green via auto submit App label Apr 1, 2024
@auto-submit auto-submit bot merged commit 40dda2b into flutter:master Apr 1, 2024
@TahaTesser TahaTesser deleted the data_column_mainAxisAlignment branch April 1, 2024 09:46
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Apr 1, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Apr 2, 2024
Manual roll requested by tarrinneal@google.com

flutter/flutter@9d32f07...7fa932b

2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from e6f19409b613 to ea93c5d91b12 (3 revisions) (flutter/flutter#146100)
2024-04-01 103135467+sealesj@users.noreply.github.com Refactor realm_checker (flutter/flutter#145905)
2024-04-01 kallentu@google.com Add info strings to code blocks. (flutter/flutter#146085)
2024-04-01 sokolovskyi.konstantin@gmail.com Add test for animated_container.0.dart API example. (flutter/flutter#145995)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8dff6b833fe2 to e6f19409b613 (2 revisions) (flutter/flutter#146093)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from d33666d90916 to 8dff6b833fe2 (3 revisions) (flutter/flutter#146087)
2024-04-01 katelovett@google.com Fix SliverMainAxisGroup layout in reverse (flutter/flutter#145572)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from dd4f5cd5c9d5 to d33666d90916 (3 revisions) (flutter/flutter#146083)
2024-04-01 engine-flutter-autoroll@skia.org Roll Packages from 51faaa1 to d5aff19 (3 revisions) (flutter/flutter#146081)
2024-04-01 102401667+Dimilkalathiya@users.noreply.github.com Fixes some gesture recognizers are not disposed. (flutter/flutter#146072)
2024-04-01 barpac02@gmail.com Flutter Gradle Plugin: add versionName and versionCode to FlutterExtension (flutter/flutter#146044)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from bf348cd73d49 to dd4f5cd5c9d5 (1 revision) (flutter/flutter#146071)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 984a78b04671 to bf348cd73d49 (1 revision) (flutter/flutter#146065)
2024-04-01 tessertaha@gmail.com Deprecate `ButtonBar`, `ButtonBarThemeData`, and `ThemeData.buttonBarTheme` (flutter/flutter#145523)
2024-04-01 tessertaha@gmail.com Add `DataColumn.headingRowAlignment ` for `DataTable` (flutter/flutter#144006)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from e9d35f8bfbe2 to 984a78b04671 (2 revisions) (flutter/flutter#146062)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4f6b832c8e33 to e9d35f8bfbe2 (1 revision) (flutter/flutter#146060)
2024-03-31 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9689390986b7 to 4f6b832c8e33 (1 revision) (flutter/flutter#146055)
2024-03-31 engine-flutter-autoroll@skia.org Roll Flutter Engine from 34081fea4d59 to 9689390986b7 (1 revision) (flutter/flutter#146053)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
TecHaxter pushed a commit to TecHaxter/flutter_packages that referenced this pull request May 22, 2024
)

Manual roll requested by tarrinneal@google.com

flutter/flutter@9d32f07...7fa932b

2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from e6f19409b613 to ea93c5d91b12 (3 revisions) (flutter/flutter#146100)
2024-04-01 103135467+sealesj@users.noreply.github.com Refactor realm_checker (flutter/flutter#145905)
2024-04-01 kallentu@google.com Add info strings to code blocks. (flutter/flutter#146085)
2024-04-01 sokolovskyi.konstantin@gmail.com Add test for animated_container.0.dart API example. (flutter/flutter#145995)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 8dff6b833fe2 to e6f19409b613 (2 revisions) (flutter/flutter#146093)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from d33666d90916 to 8dff6b833fe2 (3 revisions) (flutter/flutter#146087)
2024-04-01 katelovett@google.com Fix SliverMainAxisGroup layout in reverse (flutter/flutter#145572)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from dd4f5cd5c9d5 to d33666d90916 (3 revisions) (flutter/flutter#146083)
2024-04-01 engine-flutter-autoroll@skia.org Roll Packages from 51faaa1 to d5aff19 (3 revisions) (flutter/flutter#146081)
2024-04-01 102401667+Dimilkalathiya@users.noreply.github.com Fixes some gesture recognizers are not disposed. (flutter/flutter#146072)
2024-04-01 barpac02@gmail.com Flutter Gradle Plugin: add versionName and versionCode to FlutterExtension (flutter/flutter#146044)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from bf348cd73d49 to dd4f5cd5c9d5 (1 revision) (flutter/flutter#146071)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 984a78b04671 to bf348cd73d49 (1 revision) (flutter/flutter#146065)
2024-04-01 tessertaha@gmail.com Deprecate `ButtonBar`, `ButtonBarThemeData`, and `ThemeData.buttonBarTheme` (flutter/flutter#145523)
2024-04-01 tessertaha@gmail.com Add `DataColumn.headingRowAlignment ` for `DataTable` (flutter/flutter#144006)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from e9d35f8bfbe2 to 984a78b04671 (2 revisions) (flutter/flutter#146062)
2024-04-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 4f6b832c8e33 to e9d35f8bfbe2 (1 revision) (flutter/flutter#146060)
2024-03-31 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9689390986b7 to 4f6b832c8e33 (1 revision) (flutter/flutter#146055)
2024-03-31 engine-flutter-autoroll@skia.org Roll Flutter Engine from 34081fea4d59 to 9689390986b7 (1 revision) (flutter/flutter#146053)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC bmparr@google.com,rmistry@google.com,stuartmorgan@google.com,tarrinneal@google.com on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DataTable] Unable to center the label of a DataColumn without side effects

4 participants