- 添加 CodeGraph、Android 和通用 gitignore 配置 - 创建项目元数据文件跟踪 Flutter 项目属性 - 添加 Codex AI 指导文档 AGENTS.md 说明项目架构 - 配置代码分析选项 analysis_options.yaml - 设置 Android 应用清单权限和 Kiosk 模式配置 - 实现中英文国际化支持 AppLocalizations - 配置 GoRouter 应用路由导航 - 创建明亮工业控制风格的主题配置 AppTheme
82 lines
2.4 KiB
Dart
82 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../../core/theme/app_theme.dart';
|
|
|
|
/// Toast 服务
|
|
/// 统一的消息提示管理
|
|
class ToastService {
|
|
/// 显示成功提示
|
|
static void showSuccess(BuildContext context, String message) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Row(
|
|
children: [
|
|
const Icon(Icons.check_circle, color: Colors.white, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(child: Text(message)),
|
|
],
|
|
),
|
|
backgroundColor: AppTheme.successColor,
|
|
duration: const Duration(seconds: 3),
|
|
behavior: SnackBarBehavior.floating,
|
|
margin: const EdgeInsets.all(16),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 显示错误提示
|
|
static void showError(BuildContext context, String message) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Row(
|
|
children: [
|
|
const Icon(Icons.error, color: Colors.white, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(child: Text(message)),
|
|
],
|
|
),
|
|
backgroundColor: AppTheme.errorColor,
|
|
duration: const Duration(seconds: 4),
|
|
behavior: SnackBarBehavior.floating,
|
|
margin: const EdgeInsets.all(16),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 显示警告提示
|
|
static void showWarning(BuildContext context, String message) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Row(
|
|
children: [
|
|
const Icon(Icons.warning, color: Colors.white, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(child: Text(message)),
|
|
],
|
|
),
|
|
backgroundColor: AppTheme.warningColor,
|
|
duration: const Duration(seconds: 3),
|
|
behavior: SnackBarBehavior.floating,
|
|
margin: const EdgeInsets.all(16),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// 显示信息提示
|
|
static void showInfo(BuildContext context, String message) {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
SnackBar(
|
|
content: Row(
|
|
children: [
|
|
const Icon(Icons.info, color: Colors.white, size: 20),
|
|
const SizedBox(width: 12),
|
|
Expanded(child: Text(message)),
|
|
],
|
|
),
|
|
backgroundColor: AppTheme.primaryColor,
|
|
duration: const Duration(seconds: 3),
|
|
behavior: SnackBarBehavior.floating,
|
|
margin: const EdgeInsets.all(16),
|
|
),
|
|
);
|
|
}
|
|
} |