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

Removed ListTile accentColor dependency #77004

Merged

Conversation

HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Mar 1, 2021

This PR removes the ListTile widget's accentColor dependency per #56918.

ListTile used the accentColor for title text and for leading/trailing icons, in selected:true tiles, when the ListTileTheme did not specify a selectedColor. The Color scheme's primary color is now used instead.

If the ListTileTheme doesn't specify a non-null value for selectedColor, the new default icon colors for the tile's leading and trailing widgets, and the default text color for the titles' descendant text widgets:

brightness new (selected:true) old (selected: true)
light colorScheme.primary primaryColor
dark colorScheme.primary accentColor

These colors should be indistinguishable from the original version when using one of the default themes.

The text and icon colors for selected:false tiles have not changed.

Breaking change

This is a breaking change, although most apps will not notice the change from theme.primaryColor to theme.colorScheme.primary, because they are typically the same color. Apps should use the ListTileTheme's selectedColor to override the default.

import 'package:flutter/material.dart';

class Sample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListTileTheme(
        selectedColor: Colors.orange,
        child: Container(
          padding: const EdgeInsets.all(32),
          alignment: Alignment.center,
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              ListTile(
                selected: true,
                title: Text('selected'),
                leading: Icon(Icons.android),
                trailing: Text('trailing')
              ),
              SizedBox(height: 32),
              ListTile(
                selected: false,
                title: Text('unselected'),
                leading: Icon(Icons.android),
                trailing: Icon(Icons.android),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData.light(),
      home: Scaffold(body: Sample())
    ),
  );
}

This PR was tested against internal Google apps in cl/360280942

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Mar 1, 2021
@google-cla google-cla bot added the cla: yes label Mar 1, 2021
@flutter-dashboard flutter-dashboard bot added the team Infra upgrades, team productivity, code health, technical debt. See also team: labels. label Mar 1, 2021
@HansMuller HansMuller force-pushed the remove_accent_color_in_list_tile branch from bf87c9e to 3ada080 Compare March 8, 2021 19:59
Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

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

LGTM, but there are some failing tests.

@HansMuller
Copy link
Contributor Author

There was a old dependency on accentColor in a dev/test_apps/stocks. I've removed it. That should clear up the failing test.

@fluttergithubbot fluttergithubbot merged commit 49ff0d9 into flutter:master Mar 8, 2021
@HansMuller HansMuller deleted the remove_accent_color_in_list_tile branch March 9, 2021 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team Infra upgrades, team productivity, code health, technical debt. See also team: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants