@@ -6,17 +6,18 @@ class GFAccordion extends StatefulWidget {
66 {Key key,
77 this .child,
88 this .content,
9- this .titlebackgroundColor,
9+ this .collapsedTitlebackgroundColor = Colors .white,
10+ this .expandedTitlebackgroundColor= const Color (0xFFE0E0E0 ),
1011 this .collapsedIcon = const Icon (Icons .keyboard_arrow_down),
1112 this .expandedIcon = const Icon (Icons .keyboard_arrow_up),
1213 this .title,
1314 this .textStyle = const TextStyle (color: Colors .black, fontSize: 16 ),
14- this .titlePadding,
15+ this .titlePadding = const EdgeInsets . all ( 10 ) ,
1516 this .contentbackgroundColor,
16- this .contentPadding,
17+ this .contentPadding = const EdgeInsets . all ( 10 ) ,
1718 this .contentChild,
18- this .titleborderColor,
19- this .contentBorderColor,
19+ this .titleborderColor = const Border () ,
20+ this .contentBorderColor = const Border () ,
2021 this .margin})
2122 : super (key: key);
2223
@@ -29,8 +30,11 @@ class GFAccordion extends StatefulWidget {
2930 /// contentChild of type [Widget] is alternative to content key. content will get priority over contentChild
3031 final Widget contentChild;
3132
32- /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title
33- final dynamic titlebackgroundColor;
33+ /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title when it is collapsed
34+ final dynamic collapsedTitlebackgroundColor;
35+
36+ /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion] title when it is expanded
37+ final dynamic expandedTitlebackgroundColor;
3438
3539 ///collapsedIcon of type [Widget] which is used to show when the [GFAccordion] is collapsed
3640 final Widget collapsedIcon;
@@ -113,15 +117,10 @@ class _GFAccordionState extends State<GFAccordion>
113117 },
114118 child: Container (
115119 decoration: BoxDecoration (
116- border: widget.titleborderColor ?? Border (),
117- color: showAccordion
118- ? widget.titlebackgroundColor != null
119- ? widget.titlebackgroundColor
120- : Color (0xFFE0E0E0 )
121- : widget.titlebackgroundColor),
122- padding: widget.titlePadding != null
123- ? widget.titlePadding
124- : EdgeInsets .all (10 ),
120+ border: widget.titleborderColor,
121+ color: showAccordion ? widget.expandedTitlebackgroundColor: widget.collapsedTitlebackgroundColor),
122+ padding: widget.titlePadding
123+ ,
125124 child: Row (
126125 mainAxisAlignment: MainAxisAlignment .spaceBetween,
127126 children: < Widget > [
@@ -138,15 +137,13 @@ class _GFAccordionState extends State<GFAccordion>
138137 showAccordion
139138 ? Container (
140139 decoration: BoxDecoration (
141- border: widget.contentBorderColor ?? Border () ,
140+ border: widget.contentBorderColor,
142141 color: widget.contentbackgroundColor != null
143142 ? widget.contentbackgroundColor
144143 : Colors .white70,
145144 ),
146145 width: MediaQuery .of (context).size.width,
147- padding: widget.contentPadding != null
148- ? widget.contentPadding
149- : EdgeInsets .all (10 ),
146+ padding: widget.contentPadding ,
150147 child: SlideTransition (
151148 position: offset,
152149 child: widget.content != null
0 commit comments