📅  最后修改于: 2023-12-03 15:15:08.076000             🧑  作者: Mango
Flutter is a framework developed by Google for building high-performance, cross-platform mobile applications for Android, iOS, and web. The focus of Flutter is on beautiful, fast UIs and high-performance apps with easy-to-use and customizable widgets.
RFlutter Alert is a package that provides an easy way to create beautiful and customizable alerts for Flutter applications. With RFlutter Alert, you can create pop-up dialogs, confirm dialogs, success dialogs, error dialogs, and more.
To use RFlutter Alert in your Flutter project, you need to add it to your pubspec.yaml file:
dependencies:
rflutter_alert: ^3.0.0
Then, run the following command to install the package:
flutter packages get
To use RFlutter Alert, you need to import the package:
import 'package:rflutter_alert/rflutter_alert.dart';
To create an alert dialog, you can use the Alert
class:
Alert(
context: context,
title: "RFLUTTER ALERT",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
You can customize the appearance of the alert dialog by passing configuration options to the Alert
constructor:
Alert(
context: context,
type: AlertType.success,
title: "SUCCESS",
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),
),
],
).show();
To create a confirm dialog, use the Alert.confirm
constructor:
Alert.confirm(
context: context,
title: "RFLUTTER ALERT",
desc: "Are you sure to delete this item?",
confirmButtonColor: Colors.red,
cancelButtonColor: Colors.blue,
buttons: [
DialogButton(
child: Text(
"CANCEL",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Color.fromRGBO(0, 179, 134, 1.0),
),
DialogButton(
child: Text(
"DELETE",
style: TextStyle(color: Colors.white, fontSize: 20),
),
onPressed: () => Navigator.pop(context),
color: Colors.red,
),
],
).show();
To create a success dialog, use the Alert.success
constructor:
Alert.success(
context: context,
title: "SUCCESS",
desc: "Flutter is more awesome with RFlutter Alert.",
).show();
To create an error dialog, use the Alert.error
constructor:
Alert.error(
context: context,
title: "ERROR",
desc: "Oops! Something went wrong.",
).show();
RFlutter Alert is a great package that provides a simple and easy way to create beautiful and customizable alerts in your Flutter apps. With RFlutter Alert, you can create various types of alerts such as pop-up dialogs, confirm dialogs, success dialogs, and error dialogs. You can fully customize the appearance of the alerts to match your app's design. So, if you want to add some beautiful and user-friendly alerts to your Flutter app, give RFlutter Alert a try!