apptomate_custom_toast 0.0.1
apptomate_custom_toast: ^0.0.1 copied to clipboard
CustomToast is an enhanced toast notification system for Flutter that provides more flexibility and visual appeal than standard snackbars.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:apptomate_custom_toast/apptomate_custom_toast.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const CustomToastWidget(),
);
}
}
class CustomToastWidget extends StatelessWidget {
const CustomToastWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("Custom Toast Example")),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
CustomToast.show(
context,
message: "Success! Operation completed.",
backgroundColor: Colors.green,
textColor: Colors.white,
fontSize: 14.0,
duration: const Duration(seconds: 3),
borderRadius: 12.0,
icon: Icons.check_circle_outline,
iconColor: Colors.white,
iconSize: 28.0,
position: ToastPosition.bottom,
onToastClosed: () {
debugPrint("Toast closed");
},
);
},
child: const Text("Show Success Toast"),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
CustomToast.show(
context,
message: "Warning: This action cannot be undone.",
backgroundColor: Colors.orange,
textColor: Colors.white,
fontSize: 14.0,
fontWeight: FontWeight.bold,
duration: const Duration(seconds: 4),
borderRadius: 12.0,
icon: Icons.warning_amber_outlined,
iconColor: Colors.white,
iconSize: 28.0,
position: ToastPosition.top,
offset: 150.0,
dismissible: true,
);
},
child: const Text("Show Warning Toast (Top)"),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: () {
CustomToast.show(
context,
message: "Error! Something went wrong. Please try again later.",
backgroundColor: Colors.red,
textColor: Colors.white,
fontSize: 14.0,
duration: const Duration(seconds: 5),
borderRadius: 12.0,
icon: Icons.error_outline,
iconColor: Colors.white,
iconSize: 28.0,
position: ToastPosition.center,
animationCurve: Curves.bounceOut,
);
},
child: const Text("Show Error Toast (Center)"),
),
],
),
),
);
}
}