elegant_notification 1.6.3
elegant_notification: ^1.6.3 copied to clipboard
A new flutter package to display notifications on top of the screen, full customizable with built-in themes
example/lib/main.dart
import 'package:elegant_notification/elegant_notification.dart';
import 'package:elegant_notification/resources/arrays.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
body: ExampleApp(),
),
);
}
}
class ExampleApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
ElegantNotification.success(
title: Text('Update'),
description: Text('Your data has been updated'),
notificationPosition: NotificationPosition.bottom,
onDismiss: () {
print(
'This print will be displayed when dismissing the popup',
);
},
).show(context);
},
child: Container(
width: 150,
height: 150,
color: Colors.blue,
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Success theme notification',
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
),
),
SizedBox(
width: 20,
),
InkWell(
onTap: () {
ElegantNotification.error(
title: Text('Error'),
description: Text('Please verifiy your data'),
onDismiss: () {
print(
'This print will be displayed when dismissing the popup',
);
},
).show(context);
},
child: Container(
width: 150,
height: 150,
color: Colors.blue,
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Error theme notification',
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
),
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
ElegantNotification.info(
title: Text('Info'),
description: Text(
'This account will be updated once you exit',
),
showProgressIndicator: false,
onDismiss: () {
print(
'This print will be displayed when dismissing the popup',
);
},
).show(context);
},
child: Container(
width: 150,
height: 150,
color: Colors.blue,
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Info theme notification',
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
),
),
SizedBox(
width: 20,
),
InkWell(
onTap: () {
ElegantNotification(
title: Text(
'New version',
style: TextStyle(
color: Colors.red,
),
),
description: Text(
'A new version is available to you please update.',
),
icon: Icon(
Icons.access_alarm,
color: Colors.orange,
),
progressIndicatorColor: Colors.orange,
onDismiss: () {
print(
'This print will be displayed when dismissing the popup',
);
},
).show(context);
},
child: Container(
width: 150,
height: 150,
color: Colors.blue,
child: Center(
child: Text(
'Custom notification',
style: TextStyle(color: Colors.white),
),
),
),
),
],
),
SizedBox(
height: 20,
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () {
ElegantNotification.info(
title: Text('Info'),
description: Text(
'This account will be updated once you exit',
),
action: Text(
'Link',
style: TextStyle(
decoration: TextDecoration.underline,
color: Colors.blue,
),
),
onActionPressed: () {},
showProgressIndicator: false,
onDismiss: () {
print(
'This print will be displayed when dismissing the popup',
);
},
).show(context);
},
child: Container(
width: 150,
height: 150,
color: Colors.blue,
child: Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Notification with action',
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
),
),
SizedBox(
width: 20,
),
InkWell(
onTap: () {
ElegantNotification(
notificationPosition: NotificationPosition.bottom,
description: Text(
'A new version is available to you please update.',
),
icon: Icon(
Icons.access_alarm,
color: Colors.orange,
),
progressIndicatorColor: Colors.orange,
showProgressIndicator: false,
autoDismiss: false,
onDismiss: () {
print(
'This print will be displayed when dismissing the popup',
);
},
).show(context);
},
child: Container(
width: 150,
height: 150,
color: Colors.blue,
child: Center(
child: Text(
'Elegant notification without title',
style: TextStyle(color: Colors.white),
textAlign: TextAlign.center,
),
),
),
),
],
),
],
),
);
}
}