Skip to content

Instantly share code, notes, and snippets.

@Vanchel
Last active July 21, 2023 09:57
Show Gist options
  • Save Vanchel/763cbbb4b0c108afa6e81eeca51442e1 to your computer and use it in GitHub Desktop.
Save Vanchel/763cbbb4b0c108afa6e81eeca51442e1 to your computer and use it in GitHub Desktop.
Test case for implementing a custom job interview checkbox
import 'package:flutter/material.dart';
void main() => runApp(const CheckboxExampleApp());
class CheckboxExampleApp extends StatelessWidget {
const CheckboxExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Checkbox Sample')),
body: const Center(
child: CheckboxExample(),
),
),
);
}
}
class CheckboxExample extends StatefulWidget {
const CheckboxExample({super.key});
@override
State<CheckboxExample> createState() => _CheckboxExampleState();
}
class _CheckboxExampleState extends State<CheckboxExample> {
bool isChecked = false;
@override
Widget build(BuildContext context) {
return MyCheckbox(
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value!;
});
},
);
}
}
class MyCheckbox extends StatefulWidget {
const MyCheckbox({
super.key,
required this.value,
required this.onChanged,
});
final bool value;
final ValueChanged<bool> onChanged;
@override
State<MyCheckbox> createState() => _MyCheckboxState();
}
class _MyCheckboxState extends State<MyCheckbox> {
@override
Widget build(BuildContext context) {
return Container(
width: 40,
height: 40,
color: Colors.red,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment