I am completely new to flutter and I am trying to make an application that has 7 switches for each day of the week.
The problem is resolved when a create 7 different switchlisttile with different values for each one.
But when I extracted the method, the switches don't work.
here is the code below:
Column(
children: <Widget>[
buildSwitchListTile(Title : "Monday" , Value : Value1),
buildSwitchListTile(Title : "Tuesday" , Value : Value2),
buildSwitchListTile(Title : "Wednesday" , Value : Value3),
buildSwitchListTile(Title : "Thursday" , Value : Value4),
buildSwitchListTile(Title : "Friday" , Value : Value5),
buildSwitchListTile(Title : "Saturday" , Value : Value6),
buildSwitchListTile(Title : "Sunday" , Value : Value7),
],
),
The extracted method:
SwitchListTile buildSwitchListTile({String Title , bool Value}) {
return SwitchListTile(
title: Text(Title),
value: Value1,
onChanged: (bool value) => setState(() {
Value1 = value;
}),
);
}
However I am aware that I have used Value1 in the method above, the reason is without it the switches don't work.