Created
December 15, 2022 17:04
-
-
Save omarzer0/eb32b768a5fa48dfed02c604a1902402 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:another_flushbar/flushbar.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
showSemanticsDebugger: false, | |
home: LoginScreen(), | |
), | |
); | |
} | |
class LoginScreen extends StatefulWidget { | |
@override | |
State<LoginScreen> createState() => _LoginScreenState(); | |
} | |
class _LoginScreenState extends State<LoginScreen> { | |
Flushbar? flushbar; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(), | |
body: Column( | |
children: [ElevatedButton(onPressed: () { | |
msg(); | |
}, child: Text('Alert')), | |
], | |
), | |
); | |
} | |
void msg() { | |
Flushbar( | |
title: 'Error', | |
message: 'Invalid username or password', | |
duration: Duration(seconds: 4), | |
icon: Icon( | |
Icons.highlight_remove_outlined, | |
size: 28, | |
color: Colors.white, | |
), | |
backgroundColor: Colors.red, | |
flushbarPosition: FlushbarPosition.TOP, | |
margin: EdgeInsets.symmetric(horizontal: 10), | |
borderRadius: BorderRadius.circular(8), | |
); | |
flushbar?.show(context); | |
} | |
/** | |
* msg method version to stop duplicate flush showing | |
* (cancels the old one and start a new one)*/ | |
// void msg() { | |
// flushbar?.dismiss(); | |
// flushbar = Flushbar( | |
// title: 'Error', | |
// message: 'Invalid username or password', | |
// duration: Duration(seconds: 4), | |
// icon: Icon( | |
// Icons.highlight_remove_outlined, | |
// size: 28, | |
// color: Colors.white, | |
// ), | |
// backgroundColor: Colors.red, | |
// flushbarPosition: FlushbarPosition.TOP, | |
// margin: EdgeInsets.symmetric(horizontal: 10), | |
// borderRadius: BorderRadius.circular(8), | |
// ); | |
// flushbar?.show(context); | |
// } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment