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

Friendly way to customize checkbox style #101

Closed
omensight opened this issue Nov 24, 2021 · 3 comments
Closed

Friendly way to customize checkbox style #101

omensight opened this issue Nov 24, 2021 · 3 comments

Comments

@omensight
Copy link

Hello, I am studying the source code of this package but I cannot understand exactly how to customize the checkbox color states

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 24, 2021

Checkbox(
  ...,
  style: CheckboxThemeData(
    // this decoration will be used when `value` is `true`
    checkedDecoration: ButtonState.resolveWith(
        (states) => BoxDecoration(
          color: Colors.black,
        ),
      ),
  ),
  // this will be used when false
  uncheckedDecoration: ButtonState.resolveWith(
        (states) => BoxDecoration(
          color: Colors.white
        ),
      ),
  // this when`value` is `null`
  thirdstateDecoration: ButtonState.resolveWith(
        (states) => BoxDecoration(
          borderRadius: radius,
          color: ButtonThemeData.checkedInputColor(style, states),
        ),
      ),
)

@omensight
Copy link
Author

Checkbox(
  ...,
  style: CheckboxThemeData(
    // this decoration will be used when `value` is `true`
    checkedDecoration: ButtonState.resolveWith(
        (states) => BoxDecoration(
          color: Colors.black,
        ),
      ),
  ),
  // this will be used when false
  uncheckedDecoration: ButtonState.resolveWith(
        (states) => BoxDecoration(
          color: Colors.white
        ),
      ),
  // this when`value` is `null`
  thirdstateDecoration: ButtonState.resolveWith(
        (states) => BoxDecoration(
          borderRadius: radius,
          color: ButtonThemeData.checkedInputColor(style, states),
        ),
      ),
)

Thanks but when the cursor is positioned over the Checkbox, the Checkbox does not vanish its color, why is that?

@bdlukaa
Copy link
Owner

bdlukaa commented Nov 24, 2021

you can perform checks on states. states.isHovering, states.isPressing, and so on...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants