main.dart
import 'package:flutter/material.dart';
void main() => runApp(const FlutterExample());
class FlutterExample extends StatelessWidget {
const FlutterExample({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Example',
theme: ThemeData(primarySwatch: Colors.pink),
home: const StateExample()
);
}
}
class StateExample extends StatefulWidget {
const StateExample({Key? key}) : super(key: key);
@override
_StateExampleState createState() => _StateExampleState();
}
class _StateExampleState extends State<StateExample> {
bool checkedStatus = false;
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
title: const Text("Flutter - Checkbox Border Color")
),
body: bodyContent()
);
}
bodyContent() {
return Center(
child: Theme(
child: Checkbox(
value: checkedStatus,
onChanged: (bool? value){
setState(() {
checkedStatus = value??checkedStatus;
});
},
),
data: ThemeData(
// checked color
primarySwatch: Colors.pink,
// border color
unselectedWidgetColor: Colors.green
),
)
);
}
}
More flutter tutorials
- flutter – InkWell rounded
- flutter – Stack center
- flutter – Stack fit
- flutter – LinearProgressIndicator example
- flutter – LinearProgressIndicator width
- flutter – CircularProgressIndicator example
- flutter – CircularProgressIndicator with percentage
- flutter – LinearProgressIndicator percentage
- flutter – How to create rounded corners ToggleButtons
- flutter – How to use ToggleButtons onPressed
- flutter – How to show vertical ToggleButtons
- flutter – Checkbox example
- flutter – RangeSlider labels
- flutter – PageView example
- flutter – PageView disable swipe