showMassageDialog function

void showMassageDialog(
  1. BuildContext context,
  2. String content, {
  3. String? title,
  4. String? colorContent,
  5. String? buttonText = '知道了',
  6. VoidCallback? onPressed,
  7. TextStyle? titleStyle,
  8. bool left = false,
})

Implementation

void showMassageDialog(BuildContext context, String content,
    {String? title,
    String? colorContent,
    String? buttonText = '知道了',
    VoidCallback? onPressed,
    TextStyle? titleStyle,
    bool left = false}) {
  showDialog(
    context: context,
    barrierDismissible: false,
    builder: (ctx) => CupertinoAlertDialog(
      title: Text(title ?? "提示", style: titleStyle),
      content: GestureDetector(
        child: Container(
          alignment: left ? Alignment.centerLeft : Alignment.center,
          padding: const EdgeInsets.only(top: 10),
          child: buildSearchSpan(content, colorContent ?? '',
              style: const TextStyle(height: 1.5, color: Colors.black)),
        ),
      ),
      actions: <Widget>[
        CupertinoButton(
          child: Text(buttonText ?? "知道了",
              style: TextStyle(color: Theme.of(context).primaryColor)),
          onPressed: () {
            if (onPressed != null) {
              onPressed();
            } else {
              Navigator.pop(context);
            }
          },
        )
      ],
    ),
  );
}