flutter_toast_bar 0.0.2 flutter_toast_bar: ^0.0.2 copied to clipboard
An alert toast package to show snackbar easily. To show all validation and local messages.
import 'package:flutter/material.dart';
import 'package:flutter_toast_bar/flutter_toast_bar.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(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Toast Message Bar"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
FlutterToastBar.showToast(
context: context,
message: 'Show Snackbar Success',
backgroundColor: Colors.green);
},
child: const Text("Show Snackbar: Success"),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
FlutterToastBar.showToast(
context: context,
message: 'Show Snackbar Error',
backgroundColor: Colors.red);
},
child: const Text("Show Snackbar: Error"),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () {
FlutterToastBar.showToast(
context: context, message: 'Show Snackbar');
},
child: const Text("Show Snackbar"),
),
],
),
)
);
}
}