flutter_stack_toast 0.0.2 flutter_stack_toast: ^0.0.2 copied to clipboard
Stack toast flutter package
Features #
- Configurable toast view
- Slide to dismiss
- Auto dismissible
- Can show custom widget as toast
- Simple toast view
- Stack toast view
Getting started #
Add this line to pubspec.yaml file:
flutter_stack_toast: ^0.0.2
// add the import statement
import 'package:flutter_stack_toast/flutter_stack_toast.dart';
Usage #
For showing toast you have three methods in "FlutterToast" class:
show Simple Toast: The only input needed in this method, is the text
StackToast.showToast(buildContext, "desired text");
showTextToast: You can customize your toast more with this method, using the whole Text widget instead of the String
StackToast.showTextToast(buildContext, Text("desired text" , TextStyle(color: Colors.black, fontSize: 15)));
showCustomToast: This one is the most customizable, allowing you to use any widget you prefer.
StackToast.showCustomToast(buildContext, Text("desired text" , TextStyle(color: Colors.black, fontSize: 15)));
You can dismiss all showing and queued toast widgets with clear method:
StackToast.clear(buildContext);
You can also change all the default configs:
FadeToastConfig()
.setAlignment(ToastAlignment.bottom)
.setHorizontalMargin(10)
.setVerticalMargin(10)
.setSimpleItemHeight(40)
.setBoxShadow(BoxShadow(
color: Colors.black12,
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 1),
))
.setBorderRadius(BorderRadius.all(Radius.circular(12.0)))
.setBackgroundColor(Colors.white)
.setAnimationDuration(Duration(milliseconds: 300));
show Stack Toast: The only input needed in this method, is the text
StackToast.showStackToast(buildContext, "desired text");
showTextToast: You can customize your toast more with this method, using the whole Text widget instead of the String
StackToast.showStackTextToast(buildContext, Text("desired text" , TextStyle(color: Colors.black, fontSize: 15)));
showCustomToast: This one is the most customizable, allowing you to use any widget you prefer.
StackToast.showStackCustomToast(buildContext, Text("desired text" , TextStyle(color: Colors.black, fontSize: 15)));
You can dismiss all showing and queued toast widgets with clear method:
StackToast.clearStackToast(buildContext);
You can also change all the default configs:
StackToastConfig()
.setAlignment(ToastAlignment.bottom)
.setHorizontalMargin(10)
.setVerticalMargin(10)
.setSimpleItemHeight(40)
.setDownsizePercent(5)
.setBetweenItemSpace(10)
.setMaxShowingItem(5)
.setDismissDirection(TextDirection.ltr)
.setBoxShadow(BoxShadow(
color: Colors.black12,
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 1),
))
.setBorderRadius(BorderRadius.all(Radius.circular(12.0)))
.setBackgroundColor(Colors.white)
.setAnimationDuration(Duration(milliseconds: 300))
.setAutoDismissItemDuration(Duration(seconds: 3))
.setAutoDismissEnable(true);