in ExpandedPanel I put two buttons when press on the first change container contant, but setState() doesn't work to change the value of Scaffold_Syllabus* with the value of Table_Lecture***_Scaffold**
the code
class Syllabus extends StatefulWidget {
const Syllabus({super.key});
@override
State<Syllabus> createState() => _SyllabusState();
}
class _SyllabusState extends State<Syllabus> {
@override
Widget build(BuildContext context) {
Size? _size = MediaQuery.of(context).size;
Container _Scaffold_Syllabus = Container();
final Color color1 = HexColor('#3E6BA9');
return SingleChildScrollView(
child: Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ExpansionPanelList(
children: [
ExpansionPanel(
headerBuilder: (context, isExpanded) {
return Text("dc");
},
body: SingleChildScrollView(
child: Container(
padding: _size.width > 450
? EdgeInsets.all(40)
: EdgeInsets.only(top: 40),
decoration: BoxDecoration(
border: Border.all(width: 3, color: color1)),
child: Column(
children: [
Row(
children: [
Expanded(
child: Center(
child: ElevatedButton(
onPressed: () {
// the next code want change the container contant
setState(() {
_Scaffold_Syllabus =
Table_Lectures_Scaffold;
});
},
child: new Text("ترم أول",
style: TextStyle(
fontSize: _size.width <= 435
? 9
: 15)),
style: ElevatedButton.styleFrom(
foregroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? color1
: Colors.white,
backgroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? Colors.white
: color1,
),
),
),
),
Expanded(
child: Center(
child: ElevatedButton(
onPressed: () {
setState(() {
_Scaffold_Syllabus =
Table_Lectures_Scaffold;
});
},
child: new Text("ترم ثان",
style: TextStyle(
fontSize: _size.width <= 435
? 9
: 15)),
style: ElevatedButton.styleFrom(
foregroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? color1
: Colors.white,
backgroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? Colors.white
: color1,
),
),
),
),
],
),
SizedBox(
height: 10,
),
SafeArea(
child: Container(
width: 500,
height: 500,
padding: _size.width > 450
? EdgeInsets.all(40)
: EdgeInsets.only(top: 40),
decoration: BoxDecoration(
border:
Border.all(width: 3, color: color1)),
child: _Scaffold_Syllabus,
),
)
],
),
),
))
],
),
ExpandablePanel(
header: Text("منهج السنه الدراسية الرابعة"),
collapsed: Text(""),
expanded: SingleChildScrollView(
child: Container(
padding: _size.width > 450
? EdgeInsets.all(40)
: EdgeInsets.only(top: 40),
decoration: BoxDecoration(
border: Border.all(width: 3, color: color1)),
child: Column(
children: [
Row(
children: [
Expanded(
child: Center(
child: ElevatedButton(
onPressed: () {
setState(() {
_Scaffold_Syllabus =
Table_Lectures_Scaffold;
});
},
child: new Text("ترم أول",
style: TextStyle(
fontSize:
_size.width <= 435 ? 9 : 15)),
style: ElevatedButton.styleFrom(
foregroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? color1
: Colors.white,
backgroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? Colors.white
: color1,
),
),
),
),
Expanded(
child: Center(
child: ElevatedButton(
onPressed: () {
setState(() {
_Scaffold_Syllabus =
Table_Lectures_Scaffold;
});
},
child: new Text("ترم ثان",
style: TextStyle(
fontSize:
_size.width <= 435 ? 9 : 15)),
style: ElevatedButton.styleFrom(
foregroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? color1
: Colors.white,
backgroundColor: _Scaffold_Syllabus ==
Table_Lectures_Scaffold
? Colors.white
: color1,
),
),
),
),
],
),
SizedBox(
height: 10,
),
SafeArea(
child: Container(
width: 500,
height: 500,
padding: _size.width > 450
? EdgeInsets.all(40)
: EdgeInsets.only(top: 40),
decoration: BoxDecoration(
border: Border.all(width: 3, color: color1)),
child: _Scaffold_Syllabus,
),
)
],
),
),
))
],
),
),
),
);
}
}
i try to change the contant of container when i press the button, but setstate doesn't work