@@ -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;
@@ -86,6 +90,11 @@ class _GFAccordionState extends State<GFAccordion>
8690 ),
8791 );
8892 }
93+ @override
94+ void dispose () {
95+ animationController.dispose ();
96+ super .dispose ();
97+ }
8998
9099 bool showAccordion = false ;
91100
@@ -113,21 +122,10 @@ class _GFAccordionState extends State<GFAccordion>
113122 },
114123 child: Container (
115124 decoration: BoxDecoration (
116- border: widget.titleborderColor == null
117- ? widget.titleborderColor
118- : Border (
119- top: BorderSide (color: Colors .black38),
120- left: BorderSide (color: Colors .black38),
121- right: BorderSide (color: Colors .black38),
122- bottom: BorderSide (color: Colors .black38)),
123- color: showAccordion
124- ? widget.titlebackgroundColor != null
125- ? widget.titlebackgroundColor
126- : Color (0xFFE0E0E0 )
127- : widget.titlebackgroundColor),
128- padding: widget.titlePadding != null
129- ? widget.titlePadding
130- : EdgeInsets .all (10 ),
125+ border: widget.titleborderColor,
126+ color: showAccordion ? widget.expandedTitlebackgroundColor: widget.collapsedTitlebackgroundColor),
127+ padding: widget.titlePadding
128+ ,
131129 child: Row (
132130 mainAxisAlignment: MainAxisAlignment .spaceBetween,
133131 children: < Widget > [
@@ -144,20 +142,13 @@ class _GFAccordionState extends State<GFAccordion>
144142 showAccordion
145143 ? Container (
146144 decoration: BoxDecoration (
147- border: widget.contentBorderColor == null
148- ? widget.contentBorderColor
149- : Border (
150- bottom: BorderSide (color: Colors .black38),
151- left: BorderSide (color: Colors .black38),
152- right: BorderSide (color: Colors .black38)),
145+ border: widget.contentBorderColor,
153146 color: widget.contentbackgroundColor != null
154147 ? widget.contentbackgroundColor
155148 : Colors .white70,
156149 ),
157150 width: MediaQuery .of (context).size.width,
158- padding: widget.contentPadding != null
159- ? widget.contentPadding
160- : EdgeInsets .all (10 ),
151+ padding: widget.contentPadding ,
161152 child: SlideTransition (
162153 position: offset,
163154 child: widget.content != null
0 commit comments