这是indexloc提供的服务,不要输入任何密码
Skip to content

Added Checkbox support for MaterialStateBorderSide #86910

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

Merged
merged 2 commits into from
Jul 23, 2021

Conversation

HansMuller
Copy link
Contributor

@HansMuller HansMuller commented Jul 22, 2021

Fixes #81380

If the value of a checkbox's side property is a MaterialStateBorder, you can specify different border colors and widths for different states.

Screen Shot 2021-07-22 at 3 43 46 PM

import 'package:flutter/material.dart';

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  bool? value = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Checkbox(
          value: value,
          side: MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
            if (states.contains(MaterialState.selected)) {
              return BorderSide(width: 2, color: Colors.green);
            }
            return null; // use the default for other states
          }),
          onChanged: (bool? newValue) {
            setState(() { value = newValue; });
          },
        ),
      ),
    );
  }
}

void main() {
  runApp(MaterialApp(home: Home()));
}

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jul 22, 2021
@google-cla google-cla bot added the cla: yes label Jul 22, 2021
@HansMuller HansMuller requested a review from darrenaustin July 22, 2021 22:46
@HansMuller HansMuller force-pushed the checkbox_border_update branch from eeb206e to 9b05cdf Compare July 22, 2021 23:10
@flutter flutter deleted a comment from skia-gold Jul 23, 2021
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. Looks like a nice addition to the API.

@HansMuller HansMuller merged commit 60a072b into flutter:master Jul 23, 2021
@HansMuller HansMuller deleted the checkbox_border_update branch July 23, 2021 00:18
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[proposal] Add borderColor to Checkbox
2 participants