[FIXED] How to change checkbox border-color in flutter? By default, it is showing black but I want it in grey

Issue

How to change checkbox border-color in flutter? By default, it is showing black but I want it in grey.

Solution

CheckBox’s border color comes from unselectedWidgetColor of your ThemeData.

Add following ThemeData to your MaterialApp

MaterialApp(
  title: 'Flutter Demo',
  debugShowCheckedModeBanner: false,
  theme: ThemeData(
    primarySwatch: Colors.blue,
    unselectedWidgetColor: Colors.red, // <-- your color
  ),
  home: MyHomePage(title: 'Flutter Demo Home Page'),
);

If you don’t want to add color to the MaterialApp‘s ThemeData then you can wrap your CheckBox widget with Theme widget, following is the code for your reference:

Theme(
    child: Checkbox(
      value: false,
      onChanged: (_) {},
    ),
    data: ThemeData(
      primarySwatch: Colors.blue,
      unselectedWidgetColor: Colors.red, // Your color
    ),
  ),

Answered By – Kalpesh Kundanani

Answer Checked By – Mildred Charles (Easybugfix Admin)

Leave a Reply

(*) Required, Your email will not be published