v1.5.3flutter_sliding_toast
Um pacote do Flutter para exibir mensagens com estilos personalizados e comportamento de animação.
50Curtidas 618Downloads em 30 dias160Pontos Pub
AndroidiOSWebmacOSWindowsLinux
gaurishankar007/flutter_sliding_toast open-source repository details.
{"sdk":"flutter"}^1.2.0{"sdk":"flutter"}^27.0.0Texto original em inglês. Visite o GitHub para a versão atual.
Enhance your app's UI with customizable, interactive toasts! This package offers both sliding & popup styles, with features like animation control, tap actions, and multiple dismiss options.
Requires Flutter 3.47.0 or newer.
Add the following line to pubspec.yaml:
dependencies:
flutter_sliding_toast: ^1.6.0
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
iconTheme: const IconThemeData(color: Colors.white),
title: const Text('Sliding & Popup Toast'),
centerTitle: true,
),
body: SafeArea(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(width: double.maxFinite),
ElevatedButton(
onPressed: () {
InteractiveToast.slide(
context: context,
leading: _leadingWidget(),
title: const Text(
"Hi there! I'm a sliding toast 😎. "
'Dismiss me by sliding upward.',
),
trailing: _trailingWidget(),
toastStyle: const ToastStyle(titleLeadingGap: 10),
toastSetting: const SlidingToastSetting(
displayDuration: Duration(seconds: 2),
toastStartPosition: ToastPosition.top,
toastAlignment: Alignment.topCenter,
),
);
},
child: _textWidget('Sliding toast from top center'),
),
const SizedBox(height: 30),
ElevatedButton(
onPressed: () {
final overlayState = Overlay.of(context);
InteractiveToast.pop(
overlayState: overlayState,
title: const Text(
"Hi! I'm a popup toast 🐺. "
'I have fading and scaling effect.',
),
trailing: _trailingWidget(),
toastSetting: const PopupToastSetting(
animationDuration: Duration(seconds: 1),
displayDuration: Duration(seconds: 3),
),
);
},
child: _textWidget('Popup toast at bottom center'),
),
],
),
),
);
}
Text _textWidget(String text) =>
Text(text, style: const TextStyle(fontSize: 16));
Icon _trailingWidget() => const Icon(Icons.person, color: Colors.deepPurple);
Container _leadingWidget() {
return Container(
width: 40,
height: 40,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.purple,
boxShadow: [
BoxShadow(
color: Colors.black.withAlpha(25),
spreadRadius: 3,
blurRadius: 4,
),
],
),
alignment: Alignment.center,
child: const Text('🦄', style: TextStyle(fontSize: 20)),
);
}
}
Pull requests are welcomed!
If you encounter any problems or you have any ideas, feel free to open an issue: