status<T> static method

Future<T?> status<T>(
  1. BuildContext context, {
  2. required String status,
  3. required Widget statusIcon,
  4. IconData? closeIcon,
  5. String? description,
})

状态栏,表示成功,失败,奖励等状态的提示

用途

  • 成功/失败事件的显示,说明
  • 获取道具事件的说明
  • 仅表示一种状态的事件。

参数 |参数名|描述|是否必须|

  • context 上下文
  • status 表示状态的文字
  • statusIcon 表示状态相对于的图标
  • closeIcon 右上角关闭按钮的图标
  • description 描述文字,用于表示状态获取后的描述。

Implementation

static Future<T?> status<T>(
  BuildContext context, {
  required String status,
  required Widget statusIcon,
  IconData? closeIcon,
  String? description,
}) {
  return showDialog<T>(
    context: context,
    builder: (BuildContext context) {
      return Dialog(
        backgroundColor: Colors.transparent,
        child: Stack(
          children: [
            Container(
              padding: EdgeInsets.only(
                  top: 12.0, left: 12.0, bottom: 12.0, right: 10.0),
              margin: EdgeInsets.only(right: 18.0, top: 12.0),
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10.0),
                gradient: LinearGradient(
                  colors: [
                    Color(0x9a03A9F4),
                    Color(0xFF651FFF),
                    Color(0x9a7C4DFF),
                  ],
                  begin: Alignment.topLeft,
                  end: Alignment.bottomRight,
                ),
              ),
              child: Column(
                mainAxisSize: MainAxisSize.min,
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    width: double.infinity,
                    padding: EdgeInsets.only(bottom: 20.0, top: 20.0),
                    child: statusIcon,
                  ),
                  Container(
                    padding: EdgeInsets.only(bottom: 8.0),
                    child: Text(
                      status,
                      style: TextStyle(
                          fontSize: 28.0,
                          color: Colors.white,
                          fontWeight: FontWeight.bold),
                    ),
                  ),
                  Container(
                    child: Text(
                      description ?? "",
                      style: TextStyle(fontSize: 10.0, color: Colors.white),
                    ),
                  )
                ],
              ),
            ),
            Container(
                height: 24,
                alignment: Alignment.topRight,
                child: InkWell(
                  onTap: () {
                    Navigator.of(context).pop();
                  },
                  child: CircleAvatar(
                    backgroundColor: Colors.black54,
                    child: Icon(
                      closeIcon ?? Icons.close_rounded,
                      color: Colors.white,
                      size: 18.0,
                    ),
                  ),
                )),
          ],
        ),
      );
    },
  );
}