@@ -16,8 +16,8 @@ class GFToast extends StatefulWidget {
1616 this .type = GFToastType .basic,
1717 this .autoDismiss = true ,
1818 this .alignment,
19- this .animationDuration = const Duration (seconds : 2 ),
20- this .duration = const Duration (seconds : 2 ),
19+ this .animationDuration = const Duration (milliseconds : 300 ),
20+ this .duration = const Duration (milliseconds : 300 ),
2121 this .textStyle = const TextStyle (color: Colors .white70),
2222 }) : super (key: key);
2323
@@ -66,7 +66,7 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
6666 @override
6767 void initState () {
6868 animationController = AnimationController (
69- duration: const Duration (milliseconds : 2000 ) ,
69+ duration: widget.duration ,
7070 vsync: this ,
7171 );
7272 animation = CurvedAnimation (
@@ -109,64 +109,64 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
109109 }
110110
111111 @override
112- Widget build (BuildContext context) => hideToast
113- ? Container ()
114- : FadeTransition (
115- opacity: widget.autoDismiss ? fadeanimation : animation,
116- child: Column (
117- children: < Widget > [
118- Container (
119- width: widget.type == GFToastType .fullWidth
120- ? MediaQuery .of (context).size.width
121- : widget.width,
122- constraints: const BoxConstraints (minHeight: 50 ),
123- margin: widget.type == GFToastType .fullWidth
124- ? const EdgeInsets .only (left: 0 , right: 0 )
125- : const EdgeInsets .only (left: 10 , right: 10 ),
126- padding: const EdgeInsets .all (10 ),
127- decoration: BoxDecoration (
128- borderRadius: widget.type == GFToastType .basic
129- ? BorderRadius .circular (0 )
130- : widget.type == GFToastType .rounded
131- ? BorderRadius .circular (10 )
132- : BorderRadius .zero,
133- color: widget.backgroundColor != null
134- ? GFColors .getGFColor (widget.backgroundColor)
135- : const Color (0xff323232 ),
136- boxShadow: [
137- BoxShadow (
138- color: Colors .black.withOpacity (0.40 ),
139- blurRadius: 6 ,
140- )
141- ]),
142- child: Row (
143- children: < Widget > [
144- Flexible (
145- flex: 7 ,
146- fit: FlexFit .tight,
147- child: Align (
148- alignment: widget.alignment ?? Alignment .topLeft,
149- child: widget.text != null
150- ? Text (widget.text, style: widget.textStyle)
151- : (widget.child ?? Container ()),
152- ),
153- ),
154- const SizedBox (
155- width: 10 ,
156- ),
157- widget.button != null
158- ? Flexible (
159- flex: 4 ,
160- fit: FlexFit .tight,
161- child: Align (
162- alignment: Alignment .topRight,
163- child: widget.button,
164- ))
165- : Container ()
166- ],
112+ Widget build (BuildContext context) => hideToast? Container (): FadeTransition (
113+ opacity: widget.autoDismiss ? fadeanimation : animation,
114+ child:
115+ Column (
116+ children: < Widget > [
117+ Container (
118+ width: widget.type == GFToastType .fullWidth
119+ ? MediaQuery .of (context).size.width
120+ : widget.width?? MediaQuery .of (context).size.width* 0.885 ,
121+ constraints: const BoxConstraints (minHeight: 50 ),
122+ margin: widget.type == GFToastType .fullWidth
123+ ? const EdgeInsets .only (left: 0 , right: 0 )
124+ : const EdgeInsets .only (left: 10 , right: 10 ),
125+ padding: const EdgeInsets .all (10 ),
126+ decoration: BoxDecoration (
127+ borderRadius: widget.type == GFToastType .basic
128+ ? BorderRadius .circular (0 )
129+ : widget.type == GFToastType .rounded
130+ ? BorderRadius .circular (10 )
131+ : BorderRadius .zero,
132+ color: widget.backgroundColor != null
133+ ? GFColors .getGFColor (widget.backgroundColor)
134+ : const Color (0xff323232 ),
135+ boxShadow: [
136+ BoxShadow (
137+ color: Colors .black.withOpacity (0.40 ),
138+ blurRadius: 6 ,
139+ )
140+ ]),
141+ child: Row (
142+ children: < Widget > [
143+ Flexible (
144+ flex: 7 ,
145+ fit: FlexFit .tight,
146+ child: Align (
147+ alignment: widget.alignment ?? Alignment .topLeft,
148+ child: widget.text != null
149+ ? Text (widget.text, style: widget.textStyle)
150+ : (widget.child ?? Container ()),
151+ ),
167152 ),
168- ),
169- ],
153+ const SizedBox (
154+ width: 10 ,
155+ ),
156+ widget.button != null
157+ ? Flexible (
158+ flex: 4 ,
159+ fit: FlexFit .tight,
160+ child: Align (
161+ alignment: Alignment .topRight,
162+ child: widget.button,
163+ ))
164+ : Container ()
165+ ],
166+ ),
170167 ),
171- );
168+ ],
169+ )
170+
171+ );
172172}
0 commit comments