11import 'package:flutter/material.dart' ;
22import 'package:getflutter/colors/gf_color.dart' ;
33
4- class GFAccordian extends StatefulWidget {
5- const GFAccordian (
4+ class GFAccordion extends StatefulWidget {
5+
6+ const GFAccordion (
67 {Key key,
78 this .child,
8- this .description ,
9+ this .content ,
910 this .titlebackgroundColor,
1011 this .collapsedIcon = const Icon (Icons .keyboard_arrow_down),
11- this .expandedIcon = const Icon (Icons .keyboard_arrow_up),
12- this .text,
12+ this .expandedIcon =
13+ const Icon (Icons .keyboard_arrow_up, color: Colors .red),
14+ this .title,
1315 this .textStyle = const TextStyle (color: Colors .black, fontSize: 16 ),
1416 this .titlePadding,
1517 this .descriptionPadding,
1618 this .descriptionbackgroundColor,
19+ this .contentChild,
1720 this .margin})
1821 : super (key: key);
1922
20- /// child of type [Widget] is alternative to text key. text will get priority over child
23+ /// child of type [Widget] is alternative to title key. title will get priority over child
2124 final Widget child;
2225
23- /// description of type[Widget] which shows the messages after the [GFAccordian] is expanded
24- final Widget description;
26+ /// content of type[String] which shows the messages after the [GFAccordion] is expanded
27+ final String content;
28+
29+ /// contentChild of type [Widget] is alternative to content key. content will get priority over contentChild
30+ final Widget contentChild;
2531
26- /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordian ] title
32+ /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion ] title
2733 final dynamic titlebackgroundColor;
2834
29- ///collapsedIcon of type [Widget] which is used to show when the [GFAccordian ] is collapsed
35+ ///collapsedIcon of type [Widget] which is used to show when the [GFAccordion ] is collapsed
3036 final Widget collapsedIcon;
3137
32- ///expandedIcon of type[Widget] which is used when the [GFAccordian ] is expanded
38+ ///expandedIcon of type[Widget] which is used when the [GFAccordion ] is expanded
3339 final Widget expandedIcon;
3440
3541 /// text of type [String] is alternative to child. text will get priority over child
36- final String text ;
42+ final String title ;
3743
3844 /// textStyle of type [textStyle] will be applicable to text only and not for the child
3945 final TextStyle textStyle;
4046
41- ///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordian ] title
47+ ///titlePadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion ] title
4248 final EdgeInsets titlePadding;
4349
44- ///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordian ] description
50+ ///descriptionPadding of type [EdgeInsets] which is used to set the padding of the [GFAccordion ] description
4551 final EdgeInsets descriptionPadding;
4652
47- /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordian ] description
53+ /// type of [Color] or [GFColor] which is used to change the background color of the [GFAccordion ] description
4854 final dynamic descriptionbackgroundColor;
4955
50- ///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordian ]
56+ ///margin of type [EdgeInsets] which is used to set the margin of the [GFAccordion ]
5157 final EdgeInsets margin;
5258
5359 @override
54- _GFAccordianState createState () => _GFAccordianState ();
60+ _GFAccordionState createState () => _GFAccordionState ();
5561}
5662
57- class _GFAccordianState extends State <GFAccordian >
63+ class _GFAccordionState extends State <GFAccordion >
5864 with TickerProviderStateMixin {
5965 AnimationController animationController;
6066 AnimationController controller;
@@ -75,7 +81,7 @@ class _GFAccordianState extends State<GFAccordian>
7581 );
7682 }
7783
78- bool showAccordian = false ;
84+ bool showAccordion = false ;
7985
8086 @override
8187 Widget build (BuildContext context) {
@@ -96,7 +102,7 @@ class _GFAccordianState extends State<GFAccordian>
96102 break ;
97103 default :
98104 }
99- showAccordian = ! showAccordian ;
105+ showAccordion = ! showAccordion ;
100106 });
101107 },
102108 child: Container (
@@ -110,28 +116,30 @@ class _GFAccordianState extends State<GFAccordian>
110116 mainAxisAlignment: MainAxisAlignment .spaceBetween,
111117 children: < Widget > [
112118 Expanded (
113- child: widget.text != null
114- ? Text (widget.text , style: widget.textStyle)
119+ child: widget.title != null
120+ ? Text (widget.title , style: widget.textStyle)
115121 : (widget.child ?? Container ()),
116122 ),
117- showAccordian ? widget.expandedIcon : widget.collapsedIcon
123+ showAccordion ? widget.expandedIcon : widget.collapsedIcon
118124 ],
119125 ),
120126 ),
121127 ),
122- showAccordian
128+ showAccordion
123129 ? Container (
130+ width: MediaQuery .of (context).size.width,
124131 color: widget.descriptionbackgroundColor != null
125132 ? widget.descriptionbackgroundColor
126133 : Colors .white70,
127134 padding: widget.descriptionPadding != null
128135 ? widget.descriptionPadding
129136 : EdgeInsets .all (10 ),
130137 child: SlideTransition (
131- position: offset,
132- child: widget.description != null
133- ? widget.description
134- : Container ()))
138+ position: offset,
139+ child: widget.content != null
140+ ? Text (widget.content)
141+ : (widget.contentChild ?? Container ()),
142+ ))
135143 : Container ()
136144 ],
137145 ),
0 commit comments