搜索插件、代码仓与 APP 分类

rflutter_alert 封面
插件详情v2.0.7

rflutter_alert

RFlutter Alert 是一个超灵活且易于使用的 Flutter 弹窗/提示对话框。您可以轻松创建可重用的弹窗样式,或随意添加任意数量的按钮。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.4万
喜欢数
1070
Pub 分数
150

安装插件

flutter pub add rflutter_alert

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

RFlutter Alert 是一个可自定义且用户友好的包,用于在 Flutter 应用中创建警报和弹出对话框。它使开发者能够轻松构建可重复使用的警报样式,支持无限数量的按钮,并提供各种自定义选项,如动画、颜色和内容布局。非常适合在多个平台上显示通知、确认或交互式提示。该包与 Flutter 的小部件系统无缝集成,由 ratel.com.tr 维护。

适合场景

  • 显示确认对话框
  • 显示自定义通知
  • 创建可重用的警报模板
  • 通过弹出窗口处理用户输入
  • 实施入职提示
  • 管理表单验证警告

主要特点

  • 高度可定制的外观
  • 支持多个按钮
  • 可重用的警告样式
  • 内置动画
  • 跨平台兼容性
  • 与 Flutter 的轻松集成

适合对象

  • 初学者 Flutter 开发者
  • 需要频繁提醒的应用
  • 交互式 UI 组件
  • 多平台应用
  • 自定义对话框设计
  • 快速原型设计

使用建议

  • 可能需要额外的样式设置以适应复杂布局
  • 与完整的UI库相比,内置主题有限
  • 嵌套警报过多可能导致性能影响
  • 不适合复杂的模态工作流
  • 需要手动处理按钮回调
  • 最适合简单到中等复杂度的对话框

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

RFlutter Alert

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.

Version

Features

  • Single line basic alert
  • Adding buttons dynamically (as much as you want)
  • Predefined beautiful alert styles (success, error, warning, info)
  • Reusable alert styles
  • Super customizable
    • Change animation (fromTop, fromBottom, fromRight, fromLeft, grow, shrink) & Custom Animation
    • Set animation duration
    • Show/hide close button
    • Set overlay tap to dismiss
    • Assign Title and desc styles
    • Change dialog border style

Getting started

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

Example Project

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.

Basic Alert

Alert(context: context, title: "RFLUTTER", desc: "Flutter is awesome.").show();

Alert with Button

    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 with Buttons

    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();

Alert with Style

AlertStyle

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 with Custom Image

    Alert(
      context: context,
      title: "RFLUTTER ALERT",
      desc: "Flutter is better with RFlutter Alert.",
      image: Image.asset("assets/success.png"),
    ).show();

Alert with Custom Content

    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();

Contributions

  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Version compatability

See CHANGELOG for all breaking (and non-breaking) changes.


Made with ❤ by Ratel

所属分类

源码仓库

使用此插件的项目