smart_snackbars 1.0.0
smart_snackbars: ^1.0.0 copied to clipboard
This package facilitates you to create very highly customized SnackBars and Toasts on the go without caring about overlay.
import 'package:example/demo_helper.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Smart SnackBars Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Smart SnackBars Demo'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => DemoHelper.showTemplatedSnackbar(context),
child: Container(
color: Colors.blue,
padding: const EdgeInsets.all(8),
child: const Text(
"Show Templated SnackBar",
style: TextStyle(color: Colors.white),
),
),
),
const SizedBox(height: 10),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => DemoHelper.showCustomSnackBar(context),
child: Container(
color: Colors.blue,
padding: const EdgeInsets.all(8),
child: const Text(
"Show Dismissible SnackBar",
style: TextStyle(color: Colors.white),
),
),
),
const SizedBox(height: 10),
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () => DemoHelper.showStickySnackBar(context),
child: Container(
color: Colors.blue,
padding: const EdgeInsets.all(8),
child: const Text(
"Show Sticky SnackBar",
style: TextStyle(color: Colors.white),
),
),
),
],
),
),
);
}
}