v2.0.7rflutter_alert
RFlutter Alert 是一个超灵活且易于使用的 Flutter 弹窗/提示对话框。您可以轻松创建可重用的弹窗样式,或随意添加任意数量的按钮。
RFlutter Alert 是一个高度可定制且易于使用的 Flutter 弹出对话框/提示库。您可以轻松创建可重复使用的提示样式,或随意添加任意数量的按钮。
{"sdk":"flutter"}{"sdk":"flutter"}以下为英文项目原文快照,最新内容请访问 GitHub。
RFlutter Alert is super customizable and easy-to-use alert/popup dialogs for Flutter. You may create reusable alert styles or add buttons as much as you want with ease.
https://github.com/ozibrahim/files/raw/master/rflutter_alert_V1.0.2.gif
https://github.com/ozibrahim/files/raw/master/rflutter_alert_V1.0.2.png https://github.com/ozibrahim/files/raw/master/rflutter_alert_basic_V1.0.2.png https://github.com/ozibrahim/files/raw/master/rflutter_alert_buttons_V1.0.2.png https://github.com/ozibrahim/files/raw/master/rflutter_alert_custom_V1.0.2.png https://github.com/ozibrahim/files/raw/master/rflutter_alert_error_V1.0.2.png https://github.com/ozibrahim/files/raw/master/rflutter_alert_icon_V1.0.2.png https://github.com/ozibrahim/files/raw/master/rflutter_alert_style_V1.0.2.png
You must add the library as a dependency to your project.
dependencies:
rflutter_alert: ^2.0.7
You can also reference the git repo directly if you want:
dependencies:
rflutter_alert:
git: git://github.com/RatelHub/rflutter_alert.git
You should then run flutter packages get
There is a detailed example project in the example folder. You can directly run and play on it. There are code snippets from example project below.
Alert(context: context, title: "RFLUTTER", desc: "Flutter is awesome.").show();
Alert(
context: context,
type: AlertType.error,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
buttons: [
DialogButton(
child: Text(
"COOL",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
width: 120,
)
],
).show();
Alert(
context: context,
type: AlertType.warning,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
buttons: [
DialogButton(
child: Text(
"FLAT",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Color.fromRGBO(0, 179, 134, 1.0),
),
DialogButton(
child: Text(
"GRADIENT",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
gradient: LinearGradient(colors: [
Color.fromRGBO(116, 116, 191, 1.0),
Color.fromRGBO(52, 138, 199, 1.0)
]),
)
],
).show();
Use the AlertStyle class to customize.
var alertStyle = AlertStyle(
animationType: AnimationType.fromTop,
isCloseButton: false,
isOverlayTapDismiss: false,
descStyle: TextStyle(fontWeight: FontWeight.bold),
descTextAlign: TextAlign.start,
animationDuration: Duration(milliseconds: 400),
alertBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0.0),
side: BorderSide(
color: Colors.grey,
),
),
titleStyle: TextStyle(
color: Colors.red,
),
alertAlignment: Alignment.topCenter,
);
And assign your AlertStyle object to Alert's style field.
Alert(
context: context,
style: alertStyle,
type: AlertType.info,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
buttons: [
DialogButton(
child: Text(
"COOL",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Color.fromRGBO(0, 179, 134, 1.0),
radius: BorderRadius.circular(0.0),
),
],
).show();
Alert(
context: context,
title: "RFLUTTER ALERT",
desc: "Flutter is better with RFlutter Alert.",
image: Image.asset("assets/success.png"),
).show();
Alert(
context: context,
title: "LOGIN",
content: Column(
children: <Widget>[
TextField(
decoration: InputDecoration(
icon: Icon(Icons.account_circle),
labelText: 'Username',
),
),
TextField(
obscureText: true,
decoration: InputDecoration(
icon: Icon(Icons.lock),
labelText: 'Password',
),
),
],
),
buttons: [
DialogButton(
onPressed: () => Navigator.pop(context),
child: Text(
"LOGIN",
style: TextStyle(color: Colors.white, fontSize: 20),
),
)
]).show();
See CHANGELOG for all breaking (and non-breaking) changes.