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
),
),
I hope this helps, in case of any doubt please comment. If this answer helps you then please accept and up-vote this answer.
Answered By - Kalpesh Kundanani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.