36 lines
726 B
Dart
36 lines
726 B
Dart
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
class TaskItem extends StatefulWidget {
|
||
|
|
||
|
final bool? done;
|
||
|
|
||
|
const TaskItem({super.key, this.done});
|
||
|
|
||
|
@override
|
||
|
State<TaskItem> createState() => _TaskItemState();
|
||
|
}
|
||
|
|
||
|
class _TaskItemState extends State<TaskItem>{
|
||
|
|
||
|
bool? _done;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
_done = widget.done;
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Container(
|
||
|
alignment: Alignment.center,
|
||
|
width: 60.0,
|
||
|
height: 60.0,
|
||
|
color: Colors.white,
|
||
|
margin: const EdgeInsets.all(4.0),
|
||
|
child: _done == null ? null : Checkbox(value: _done, onChanged: (newState) => setState(() {
|
||
|
_done = newState!;
|
||
|
})),
|
||
|
);
|
||
|
}
|
||
|
}
|