the problem is the header . Im trying to build the todoye app and as you can see the call back is considered ValueChanged<bool?> not a simple function so i cant move my logic to a another statefullwidget to reduce the rebuilds in my app i tried different things but i get error evertime please help . here is my code :
import 'package:flutter/material.dart';
class TaskTile extends StatefulWidget {
@override
_TaskTileState createState() => _TaskTileState();
}
class _TaskTileState extends State<TaskTile> {
bool isChecked = false;
void checkBoxCallBack(bool checkBoxState) {
setState(() {
isChecked = checkBoxState;
});
}
@override
Widget build(BuildContext context) {
return ListTile(
title: Text(
'finish up angla\'s course today',
style: TextStyle(
decoration: isChecked ? TextDecoration.lineThrough : null,
),
),
trailing: TaskCheckBox(
checkBoxState: isChecked,
toggleCheckBoxState: checkBoxCallBack,
),
);
}
}
class TaskCheckBox extends StatelessWidget {
final bool checkBoxState;
final ValueChanged<bool?> toggleCheckBoxState;
const TaskCheckBox({
required this.checkBoxState,
required this.toggleCheckBoxState,
});
@override
Widget build(BuildContext context) {
return Checkbox(
activeColor: Colors.lime,
value: checkBoxState,
onChanged: toggleCheckBoxState,
);
}
}
the error is on line 27 ...where i want to pass my custom Function to varaible of my statelessWidget.