Skip to content

Conversation

@QuncCccccc
Copy link
Contributor

This PR added an error state for the Checkbox. Fixes #104446

Screen Shot 2022-09-07 at 4 31 42 PMScreen Shot 2022-09-07 at 4 32 34 PM

In order to use the Checkbox with the new Material 3 defaults, turn on the useMaterial3 flag in the ThemeData:

  return MaterialApp(
    theme: ThemeData(useMaterial3: true),
    // ...
  );

This PR adds a new property isError for Checkbox. To show a checkbox in an error state, set isError to true.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos documentation f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Sep 7, 2022
@QuncCccccc QuncCccccc force-pushed the add_support_for_checkbox_error_state branch from cd2bb82 to 9c3af95 Compare September 7, 2022 23:48
@QuncCccccc QuncCccccc marked this pull request as ready for review September 8, 2022 17:02
Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

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

LGTM

// so that they can be lerped between.
final Set<MaterialState> activeStates = states..add(MaterialState.selected);
final Set<MaterialState> inactiveStates = states..remove(MaterialState.selected);
final Set<MaterialState> errorState = states..add(MaterialState.error);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is confusing to read because states refers to a getter that constructs a new set rather than a local variable or a field. The code appears to be side-effecting the same set of states in each statement, rather than implicitly generating a new one each time that states appears in an expression. No need to fix this now, however if we refactor this code in the future...

setState(() {
isChecked = value;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

trailing commas can be added here and elsewhere

expect(focusNode.hasPrimaryFocus, isFalse);
expect(
Material.of(tester.element(find.byType(Checkbox))),
paints..path(color: theme.colorScheme.error)..path(color: theme.colorScheme.onError)
Copy link
Contributor

@bleroux bleroux Sep 8, 2022

Choose a reason for hiding this comment

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

nit: remove indent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos 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.

Clean checkbox colors so they use the material 3 palette

3 participants