Skip to content

Commit d9a1a87

Browse files
committed
gf-toast done
1 parent c30f082 commit d9a1a87

File tree

1 file changed

+59
-53
lines changed

1 file changed

+59
-53
lines changed

lib/components/toast/gf_toast.dart

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
8282
begin: 0.0,
8383
end: 1.0,
8484
).animate(fadeanimationController);
85-
Timer(widget.duration,(){
85+
Timer(widget.duration, () {
8686
fadeanimationController.forward();
8787
});
8888

@@ -91,8 +91,8 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
9191
end: 0.0,
9292
).animate(fadeanimationController);
9393

94-
fadeanimation.addStatusListener((AnimationStatus state){
95-
if(fadeanimation.isCompleted && widget.autoDismiss){
94+
fadeanimation.addStatusListener((AnimationStatus state) {
95+
if (fadeanimation.isCompleted && widget.autoDismiss) {
9696
setState(() {
9797
hideToast = true;
9898
});
@@ -110,59 +110,65 @@ class _GFToastState extends State<GFToast> with TickerProviderStateMixin {
110110

111111
@override
112112
Widget build(BuildContext context) {
113-
return hideToast?Container(): FadeTransition(
114-
opacity: widget.autoDismiss ? fadeanimation : animation,
115-
child: Column(
116-
children: <Widget>[
117-
Container(
118-
width: widget.type == GFToastType.fullWidth? MediaQuery.of(context).size.width:widget.width,
119-
constraints: BoxConstraints(minHeight: 50.0),
120-
margin: widget.type == GFToastType.fullWidth
121-
? EdgeInsets.only(left: 0, right: 0)
122-
: EdgeInsets.only(left: 10, right: 10),
123-
padding: EdgeInsets.all(10),
124-
decoration: BoxDecoration(
125-
borderRadius: widget.type == GFToastType.basic
126-
? BorderRadius.circular(0.0)
127-
: widget.type == GFToastType.rounded
128-
? BorderRadius.circular(10.0)
129-
: BorderRadius.zero,
130-
color: widget.backgroundColor != null
131-
? getGFColor(widget.backgroundColor)
132-
: Color(0xff323232),
133-
boxShadow: [
134-
BoxShadow(
135-
color: Colors.black.withOpacity(0.40), blurRadius: 6.0)
136-
]),
137-
child: Row(
113+
return hideToast
114+
? Container()
115+
: FadeTransition(
116+
opacity: widget.autoDismiss ? fadeanimation : animation,
117+
child: Column(
138118
children: <Widget>[
139-
Flexible(
140-
flex: 7,
141-
fit: FlexFit.tight,
142-
child: Align(
143-
alignment: widget.alignment !=null ? widget.alignment: Alignment.center,
144-
child: widget.text != null
145-
? Text(widget.text, style: widget.textStyle)
146-
: (widget.child ?? Container()),
147-
)
119+
Container(
120+
width: widget.type == GFToastType.fullWidth
121+
? MediaQuery.of(context).size.width
122+
: widget.width,
123+
constraints: BoxConstraints(minHeight: 50.0),
124+
margin: widget.type == GFToastType.fullWidth
125+
? EdgeInsets.only(left: 0, right: 0)
126+
: EdgeInsets.only(left: 10, right: 10),
127+
padding: EdgeInsets.all(10),
128+
decoration: BoxDecoration(
129+
borderRadius: widget.type == GFToastType.basic
130+
? BorderRadius.circular(0.0)
131+
: widget.type == GFToastType.rounded
132+
? BorderRadius.circular(10.0)
133+
: BorderRadius.zero,
134+
color: widget.backgroundColor != null
135+
? getGFColor(widget.backgroundColor)
136+
: Color(0xff323232),
137+
boxShadow: [
138+
BoxShadow(
139+
color: Colors.black.withOpacity(0.40),
140+
blurRadius: 6.0)
141+
]),
142+
child: Row(
143+
children: <Widget>[
144+
Flexible(
145+
flex: 7,
146+
fit: FlexFit.tight,
147+
child: Align(
148+
alignment: widget.alignment != null
149+
? widget.alignment
150+
: Alignment.topLeft,
151+
child: widget.text != null
152+
? Text(widget.text, style: widget.textStyle)
153+
: (widget.child ?? Container()),
154+
)),
155+
SizedBox(
156+
width: 10,
157+
),
158+
widget.button != null
159+
? Flexible(
160+
flex: 4,
161+
fit: FlexFit.tight,
162+
child: Align(
163+
alignment: Alignment.topRight,
164+
child: widget.button,
165+
))
166+
: Container()
167+
],
168+
),
148169
),
149-
SizedBox(
150-
width: 10,
151-
),
152-
widget.button != null
153-
? Flexible(
154-
flex: 4,
155-
fit: FlexFit.tight,
156-
child: Align(
157-
alignment: Alignment.topRight,
158-
child: widget.button,
159-
))
160-
: Container()
161170
],
162171
),
163-
),
164-
],
165-
),
166-
);
172+
);
167173
}
168174
}

0 commit comments

Comments
 (0)