flutter styled toast
a styled toast flutter package. you can highly customize toast ever. beautify toast with a series of animations and make toast more beautiful.
demo
getting started
dependencies:
flutter_styled_toast: ^1.2.1
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
styledtoast(
textstyle: textstyle(fontsize: 16.0, color: colors.white),
backgroundcolor: color(0x99000000),
borderradius: borderradius.circular(5.0),
textpadding: edgeinsets.symmetric(horizontal: 17.0, vertical: 10.0),
toastpositions: styledtoastposition.bottom,
toastanimation: styledtoastanimation.fade,
reverseanimation: styledtoastanimation.fade,
curve: curves.fastoutslowin,
reversecurve: curves.fastlineartosloweasein,
duration: duration(seconds: 4),
animduration: duration(seconds: 1),
dismissotheronshow: true,
movingonwindowchange: true,
child: materialapp(
title: apptitle,
showperformanceoverlay: showperformance,
home: layoutbuilder(
builder: (buildcontext context, boxconstraints constraints) {
return myhomepage(
title: apptitle,
onsetting: onsettingcallback,
);
},
),
),
);
// general use
showtoast("hello styled toast");
// customize toast content widget
showtoastwidget(text('hello styled toast'));
roadmap
defaulttoastwidget | fadeanim | slidefromtopanim |
slidefrombottomanim | slidefromleftanim | slidefromrightanim |
scaleanim | fadescaleanim | rotateanim |
faderotateanim | scalerotateanim | ondismiss |
customtoastwidget | customfailtoastwidget | customsuccesstoastwidget |
styledtoast param
property | description |
---|---|
child | widget (not null)(required) |
textalign | textalign (default textalign.center) |
textdirection | textdirection (default textdirection.ltr) |
borderradius | borderradius (borderradius.circular(5.0)) |
backgroundcolor | color (default color(0x99000000)) |
textpadding | edgeinsetsgeometry (default edgeinsets.symmetric(horizontal: 17.0,vertical: 8.0)) |
toasthorizontalmargin | double (default 50.0) |
textstyle | textstyle (default textstyle(fontsize: 16.0,fontweight: fontweight.normal,color: colors.white)) |
shapeborder | shapeborder (default roundedrectangleborder(borderradius: borderradius)) |
duration | duration (default 2.3s) |
animduration | duration (default 400 milliseconds, animduration * 2 <= duration, conditions must be met for toast to display properly) |
toastpositions | styledtoastposition (default styledtoastposition.bottom) |
toastanimation | styledtoastanimation (default styledtoastanimation.fade) |
reverseanimation | styledtoastanimation |
alignment | alignmentgeometry (default alignment.center) |
axis | axis (default axis.vertical) |
startoffset | offset |
endoffset | offset |
reversestartoffset | offset |
reverseendoffset | offset |
curve | curve (default curves.linear) |
reversecurve | curve (default curves.linear) |
dismissotheronshow | bool (default true) |
movingonwindowchange | bool (default true) |
ondismiss | voidcallback (invoked when toast dismiss) |
showtoast param
property | description |
---|---|
msg | string (not null)(required) |
context | buildcontext (if you don’t wrap app with styledtoast, context is required, otherwise, is not) |
duration | duration (default 2.3s) |
animduration | duration (default 400 milliseconds, animduration * 2 <= duration, conditions must be met for toast to display properly) |
position | styledtoastposition (default styledtoastposition.bottom) |
textstyle | textstyle (default textstyle(fontsize: 16.0,fontweight: fontweight.normal,color: colors.white)) |
textpadding | edgeinsetsgeometry (default edgeinsets.symmetric(horizontal: 17.0,vertical: 8.0)) |
backgroundcolor | color (default color(0x99000000)) |
borderradius | borderradius (borderradius.circular(5.0)) |
shapeborder | shapeborder (default roundedrectangleborder(borderradius: borderradius)) |
ondismiss | voidcallback (invoked when toast dismiss) |
textdirection | textdirection (default textdirection.ltr) |
dismissotheronshow | bool (default true) |
movingonwindowchange | bool (default true) |
toastanimation | styledtoastanimation (default styledtoastanimation.fade) |
reverseanimation | styledtoastanimation |
alignment | alignmentgeometry (default alignment.center) |
axis | axis (default axis.vertical) |
startoffset | offset |
endoffset | offset |
reversestartoffset | offset |
reverseendoffset | offset |
textalign | textalign (default textalign.center) |
curve | curve (default curves.linear) |
reversecurve | curve (default curves.linear) |
showtoastwidget param
property | description |
---|---|
widget | widget (not null)(required) |
context | buildcontext (if you don’t wrap app with styledtoast, context is required, otherwise, is not) |
duration | duration (default 2.3s) |
animduration | duration (default 400 milliseconds, animduration * 2 <= duration, conditions must be met for toast to display properly) |
ondismiss | voidcallback (invoked when toast dismiss) |
dismissotheronshow | bool (default true) |
movingonwindowchange | bool (default true) |
textdirection | textdirection (default textdirection.ltr) |
position | styledtoastposition (default ) |
animation | styledtoastanimation (default styledtoastanimation.fade) |
reverseanimation | styledtoastanimation |
alignment | alignmentgeometry (default alignment.center) |
axis | axis (default axis.vertical) |
startoffset | offset |
endoffset | offset |
reversestartoffset | offset |
reverseendoffset | offset |
curve | curve (default curves.linear) |
reversecurve | curve (default curves.linear) |
Comments are closed.