I have provided the full source code of the flutter checkbox. you can just copy and paste it into your widget.
Used padding and Sizedbox to show checkbox and label in a proper way.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class MyCheckbox extends StatefulWidget {
const MyCheckbox({Key? key}) : super(key: key);
@override
State<MyCheckbox> createState() => _MyCheckboxState();
}
class _MyCheckboxState extends State<MyCheckbox> {
bool valuetitle = true;
_onclicked(value) {
print('Clicked...' + value.toString());
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text(
"CodingMSTR.com",
style: TextStyle(
color: Colors.white, fontWeight: FontWeight.normal, fontSize: 18),
),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(0, 14, 0, 0),
child: Row(children: <Widget>[
SizedBox(
height: 40.0,
width: 35.0,
child: Checkbox(
value: valuetitle,
onChanged: (value) {
_onclicked(valuetitle);
if (valuetitle) {
setState(() {
valuetitle = false;
});
} else {
setState(() {
valuetitle = true;
});
}
},
),
),
const SizedBox(
height: 25.0,
width: 140.0,
child: Padding(
padding: EdgeInsets.fromLTRB(0, 4, 0, 0),
child: Text(
'Show Vehicle Name',
style:
TextStyle(fontSize: 14, fontWeight: FontWeight.bold),
),
),
),
]),
),
]),
);
}
}