• Taha Tesser's avatar
    Fix `DataTable`'s `headingTextStyle` & `dataTextStyle` are not merged with... · 75797a8a
    Taha Tesser authored
    Fix `DataTable`'s `headingTextStyle` & `dataTextStyle` are not merged with default text style (#134138)
    
    fixes [Inconsistent text color on DataTable in different platforms](https://github.com/flutter/flutter/issues/114470)
    
    ### Code sample
    
    <details>
    <summary>expand to view the code sample</summary> 
    
    ```dart
    import 'package:flutter/material.dart';
    
    /// Flutter code sample for [DataTable].
    
    void main() => runApp(const DataTableExampleApp());
    
    class DataTableExampleApp extends StatelessWidget {
      const DataTableExampleApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          themeMode: ThemeMode.dark,
          theme: ThemeData(),
          darkTheme: ThemeData.dark(),
          home: Scaffold(
            appBar: AppBar(title: const Text('DataTable Sample')),
            body: const DataTableExample(),
          ),
        );
      }
    }
    
    class DataTableExample extends StatelessWidget {
      const DataTableExample({super.key});
    
      @override
      Widget build(BuildContext context) {
        return DataTable(
          headingTextStyle: const TextStyle(),
          dataTextStyle: const TextStyle(),
          columns: const <DataColumn>[
            DataColumn(
              label: Expanded(
                child: Text(
                  'Name',
                  style: TextStyle(fontStyle: FontStyle.italic),
                ),
              ),
            ),
            DataColumn(
              label: Expanded(
                child: Text(
                  'Age',
                  style: TextStyle(fontStyle: FontStyle.italic),
                ),
              ),
            ),
            DataColumn(
              label: Expanded(
                child: Text(
                  'Role',
                  style: TextStyle(fontStyle: FontStyle.italic),
                ),
              ),
            ),
          ],
          rows: const <DataRow>[
            DataRow(
              cells: <DataCell>[
                DataCell(Text('Sarah')),
                DataCell(Text('19')),
                DataCell(Text('Student')),
              ],
            ),
            DataRow(
              cells: <DataCell>[
                DataCell(Text('Janine')),
                DataCell(Text('43')),
                DataCell(Text('Professor')),
              ],
            ),
            DataRow(
              cells: <DataCell>[
                DataCell(Text('William')),
                DataCell(Text('27')),
                DataCell(Text('Associate Professor')),
              ],
            ),
          ],
        );
      }
    }
    
    ```
    
    </details>
    
    ### Before
    
    | Desktop | Mobile |
    | --------------- | --------------- |
    | <img src="https://github.com/flutter/flutter/assets/48603081/19c3908d-6b6a-4408-9c6b-da83c8efaa4a"  /> | <img src="https://github.com/flutter/flutter/assets/48603081/efda08fb-05f9-437e-be5c-6b6861babe19" width="350"  /> |
    
    ### After
    
    | Desktop | Mobile |
    | --------------- | --------------- |
    | <img src="https://github.com/flutter/flutter/assets/48603081/6bd3433f-d61f-4f35-8a2a-f7539a74f93e" /> | <img src="https://github.com/flutter/flutter/assets/48603081/5123a79b-6c2a-4bea-9fbc-64ed3e599826" width="350" /> |
    75797a8a
Name
Last commit
Last update
.github Loading commit data...
.vscode Loading commit data...
bin Loading commit data...
dev Loading commit data...
examples Loading commit data...
packages Loading commit data...
.ci.yaml Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CODEOWNERS Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
LICENSE Loading commit data...
PATENT_GRANT Loading commit data...
README.md Loading commit data...
TESTOWNERS Loading commit data...
analysis_options.yaml Loading commit data...
dartdoc_options.yaml Loading commit data...
flutter_console.bat Loading commit data...