初始化项目
This commit is contained in:
86
lib/common/util/myDialog/MyDialog.dart
Normal file
86
lib/common/util/myDialog/MyDialog.dart
Normal file
@@ -0,0 +1,86 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'my_dialog_controller.dart';
|
||||
|
||||
class MyDialog extends GetView<MyDialogController> {
|
||||
final String message;
|
||||
final int seconds;
|
||||
final Color? textColor; // 可选参数
|
||||
|
||||
MyDialog({
|
||||
required this.message,
|
||||
required this.seconds,
|
||||
this.textColor, // 可选参数的赋值
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// 设置弹窗在2秒后自动关闭
|
||||
Timer(Duration(seconds: seconds), () {
|
||||
if (Navigator.canPop(context)) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
|
||||
return Dialog(
|
||||
backgroundColor: Colors.transparent, // 使弹窗背景透明
|
||||
elevation: 0, // 去除阴影
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 232,
|
||||
maxHeight: 400,
|
||||
minHeight: 47,
|
||||
maxWidth: 400,
|
||||
),
|
||||
child: Opacity(
|
||||
opacity: 1, // 设置容器的透明度为80%
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
// color: Color(0xFF182B7C),
|
||||
color: Color(0xFFffebe9),
|
||||
border: Border.all(
|
||||
// color: Color(0xFFe60012), // 边框颜色
|
||||
color: textColor ?? Color(0xFFe60012),
|
||||
width: 1, // 边框宽度
|
||||
),
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
blurRadius: 10,
|
||||
offset: Offset(0, 4),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
message,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
// color: Color(0xFFe60012), // 边框颜色
|
||||
color: textColor ?? Color(0xFFe60012),
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user