import 'package:flutter/material.
dart';
class Checkboxs extends StatefulWidget {
const Checkboxs({super.key});
@override
State<Checkboxs> createState() => _CheckboxsState();
}
class _CheckboxsState extends State<Checkboxs> {
bool option = false;
// Define a list of colors to use for the grid items
final List<Color> colors = [
Colors.red,
Colors.green,
Colors.blue,
Colors.orange,
Colors.purple,
Colors.teal,
Colors.red,
Colors.green,
Colors.blue,
Colors.orange,
Colors.purple,
Colors.teal,
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: [
Checkbox(value: option,
onChanged: (bool? vlaue){
setState(() {
option = vlaue!;
});
}),
SizedBox(
height: 1000,
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
childAspectRatio: 2,
mainAxisSpacing: 50,
crossAxisSpacing: 50
),
itemCount: 7,
itemBuilder: (BuildContext context, int index) {
return conatainer(colors[index], 20, 20) ;
},
),
)
],
),
),
);
}
Widget conatainer(Color, Height, Width){
return Container(
color: Color,
height: Height,
width: Width,
);
}
}