Files
flutterApp/lib/features/machine_details/presentation/pages/machine_details_page.dart

791 lines
25 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
2026-02-27 14:16:29 +08:00
import 'package:go_router/go_router.dart';
import 'package:maibu_satabot_v2/core/app/app_user_cubit.dart';
import 'package:maibu_satabot_v2/core/router/route_paths.dart';
import 'package:maibu_satabot_v2/features/devices/domain/entities/device_entity.dart';
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_cubit.dart';
2026-02-27 14:16:29 +08:00
import 'package:maibu_satabot_v2/features/devices/presentation/bloc/devices_state.dart';
2026-02-26 20:36:28 +08:00
class MachineDetailsPage extends StatefulWidget {
final DeviceEntity? device;
const MachineDetailsPage({super.key, this.device});
@override
2026-02-26 20:36:28 +08:00
State<MachineDetailsPage> createState() => _MachineDetailsPageState();
}
2026-02-26 20:36:28 +08:00
class _MachineDetailsPageState extends State<MachineDetailsPage> {
late TextEditingController _nameController;
late String _deviceName;
late String _deviceId;
2026-02-27 14:16:29 +08:00
BuildContext? _dialogContext;
2026-02-27 21:04:07 +08:00
BuildContext? _editNameSheetContext;
BuildContext? _loadingDialogContext; // 解绑加载弹窗
BuildContext? _updateLoadingContext; // 修改名称加载弹窗
bool _isUpdatingName = false;
2026-02-26 20:36:28 +08:00
@override
void initState() {
super.initState();
_deviceName = (widget.device?.deviceAlias?.trim().isEmpty ?? true)
? '未知设备'
: widget.device!.deviceAlias!;
_deviceId = widget.device?.deviceName ?? '';
2026-02-27 21:04:07 +08:00
_nameController = TextEditingController(text: _deviceName);
2026-02-26 20:36:28 +08:00
}
@override
void dispose() {
_nameController.dispose();
2026-02-27 21:04:07 +08:00
// 兜底关闭所有弹窗
if (_loadingDialogContext != null &&
Navigator.canPop(_loadingDialogContext!)) {
Navigator.pop(_loadingDialogContext!);
}
if (_updateLoadingContext != null &&
Navigator.canPop(_updateLoadingContext!)) {
Navigator.pop(_updateLoadingContext!);
}
if (_dialogContext != null && Navigator.canPop(_dialogContext!)) {
Navigator.pop(_dialogContext!);
}
if (_editNameSheetContext != null &&
Navigator.canPop(_editNameSheetContext!)) {
Navigator.pop(_editNameSheetContext!);
}
2026-02-26 20:36:28 +08:00
super.dispose();
}
2026-02-27 21:04:07 +08:00
/// 弹出修改设备名称底部抽屉(保持不变)
2026-02-26 20:36:28 +08:00
void _showEditNameSheet() {
_nameController.text = _deviceName;
2026-02-27 21:04:07 +08:00
Future<void> bottomSheetFuture = showModalBottomSheet(
2026-02-26 20:36:28 +08:00
context: context,
isScrollControlled: true,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
),
builder: (ctx) {
2026-02-27 21:04:07 +08:00
_editNameSheetContext = ctx;
2026-02-26 20:36:28 +08:00
return Padding(
padding: EdgeInsets.only(
left: 20,
right: 20,
top: 20,
bottom: MediaQuery.of(ctx).viewInsets.bottom + 20,
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const Text(
"修改设备名称",
style: TextStyle(fontSize: 17, fontWeight: FontWeight.w600),
),
const SizedBox(height: 16),
TextField(
controller: _nameController,
autofocus: true,
maxLength: 20,
decoration: const InputDecoration(
hintText: "请输入设备名称",
border: OutlineInputBorder(),
2026-02-27 21:04:07 +08:00
counterText: "",
2026-02-26 20:36:28 +08:00
),
),
const SizedBox(height: 10),
Row(
children: [
Expanded(
child: OutlinedButton(
2026-02-27 21:04:07 +08:00
onPressed: () {
_isUpdatingName = false;
Navigator.pop(ctx);
},
2026-02-26 20:36:28 +08:00
child: const Text("取消"),
),
),
const SizedBox(width: 12),
Expanded(
child: OutlinedButton(
2026-02-27 21:04:07 +08:00
onPressed: _isUpdatingName
? null
: () async {
final text = _nameController.text.trim();
if (text.isEmpty) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text("名称不能为空")),
);
}
return;
}
if (text == _deviceName) {
Navigator.pop(ctx);
return;
}
setState(() => _isUpdatingName = true);
await _executeUpdateDeviceName(text);
},
child: _isUpdatingName
? const SizedBox(
width: 20,
height: 20,
child: CircularProgressIndicator(
strokeWidth: 2,
color: Colors.white,
),
)
: const Text("确认修改"),
2026-02-26 20:36:28 +08:00
),
),
],
),
],
),
);
},
);
2026-02-27 21:04:07 +08:00
bottomSheetFuture.whenComplete(() {
setState(() {
_isUpdatingName = false;
_editNameSheetContext = null;
});
});
2026-02-26 20:36:28 +08:00
}
@override
Widget build(BuildContext context) {
2026-02-26 20:36:28 +08:00
if (widget.device == null) {
2026-02-27 21:04:07 +08:00
return Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
title: const Text('设备详情'),
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios),
onPressed: () {
// 优化1:先刷新列表,再返回(保证刷新逻辑执行)
// 核心:返回上一页
Navigator.pop(context);
if (context.mounted) {
final username =
context.read<AppUserCubit>().state.user?.username ?? "";
context.read<DevicesCubit>().fetchAllDevices(username);
}
},
),
),
body: const Center(child: Text("未获取到设备信息")),
);
}
2026-02-26 20:36:28 +08:00
final currentDevice = widget.device!;
2026-02-27 14:16:29 +08:00
return BlocListener<DevicesCubit, DevicesState>(
listener: (context, state) {
2026-02-27 21:04:07 +08:00
if (state.operationType == DeviceOperationType.unbind) {
2026-02-27 14:16:29 +08:00
_handleUnbindResult(state);
}
2026-02-27 21:04:07 +08:00
if (state.operationType == DeviceOperationType.updateName) {
_handleUpdateNameResult(state);
}
2026-02-27 14:16:29 +08:00
},
child: Scaffold(
backgroundColor: const Color(0xFFF5F5F5),
appBar: AppBar(
centerTitle: true,
title: const Text(
'设备详情',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
leading: IconButton(
icon: const Icon(Icons.arrow_back_ios),
2026-02-27 21:04:07 +08:00
onPressed: () {
Navigator.pop(context);
if (context.mounted) {
final username =
context.read<AppUserCubit>().state.user?.username ?? "";
context.read<DevicesCubit>().fetchAllDevices(username);
}
},
2026-02-27 14:16:29 +08:00
),
2026-02-27 21:04:07 +08:00
elevation: 1,
backgroundColor: Colors.white,
foregroundColor: Colors.black,
),
2026-02-27 14:16:29 +08:00
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
children: [
_buildDeviceStatusCard(currentDevice),
const SizedBox(height: 16),
2026-02-27 21:04:07 +08:00
_buildBasicInfoCard(context, currentDevice),
2026-02-27 14:16:29 +08:00
const SizedBox(height: 16),
_buildResourceCenterCard(),
const SizedBox(height: 24),
_buildUnbindButton(context),
],
),
),
),
);
}
2026-02-27 21:04:07 +08:00
/// 设备状态卡片(保持不变)
Widget _buildDeviceStatusCard(DeviceEntity device) {
return Container(
padding: const EdgeInsets.all(24),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
2026-02-27 21:04:07 +08:00
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
children: [
2026-02-27 21:04:07 +08:00
Image.asset(
'assets/images/car.png',
width: 300,
fit: BoxFit.contain,
errorBuilder: (context, error, stackTrace) {
return const Icon(
Icons.device_hub,
size: 100,
color: Colors.grey,
);
},
),
const SizedBox(height: 12),
2026-02-27 21:04:07 +08:00
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
decoration: BoxDecoration(
color: device.isOnline
2026-02-27 21:04:07 +08:00
? const Color(0xFF00C853).withOpacity(0.1)
: const Color(0xFF999999).withOpacity(0.1),
borderRadius: BorderRadius.circular(12),
),
child: Text(
device.isOnline ? '在线' : '离线',
style: TextStyle(
fontSize: 14,
color: device.isOnline
? const Color(0xFF00C853)
: const Color(0xFF999999),
),
),
),
],
),
);
}
2026-02-27 21:04:07 +08:00
/// 基本信息卡片(保持不变)
Widget _buildBasicInfoCard(BuildContext context, DeviceEntity device) {
final deviceId = device.deviceName ?? '未知ID';
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
2026-02-27 21:04:07 +08:00
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 16),
child: Text(
'基本信息',
style: TextStyle(fontSize: 14, color: Color(0xFF999999)),
),
),
_buildInfoRow(
2026-02-27 21:04:07 +08:00
context: context,
icon: Icons.info_outline,
label: '设备名称',
2026-02-26 20:36:28 +08:00
trailing: GestureDetector(
2026-02-27 21:04:07 +08:00
onTap: _isUpdatingName ? null : _showEditNameSheet,
2026-02-26 20:36:28 +08:00
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
2026-02-27 21:04:07 +08:00
Text(_deviceName, style: const TextStyle(fontSize: 16)),
2026-02-26 20:36:28 +08:00
const SizedBox(width: 8),
const Icon(Icons.edit, size: 16, color: Color(0xFF007AFF)),
],
),
),
),
const Divider(height: 32, color: Color(0xFFF0F0F0)),
_buildInfoRow(
context: context,
icon: Icons.shield_outlined,
label: '设备ID',
trailing: Column(
2026-02-27 21:04:07 +08:00
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
2026-02-27 21:04:07 +08:00
width: MediaQuery.of(context).size.width - 180,
child: GestureDetector(
2026-02-27 21:04:07 +08:00
onLongPress: () => _copyToClipboard(deviceId, '设备ID已复制'),
child: Text(
deviceId,
2026-02-27 21:04:07 +08:00
textAlign: TextAlign.right,
softWrap: true,
overflow: TextOverflow.visible,
style: const TextStyle(
fontSize: 14,
color: Colors.black87,
),
),
),
),
2026-02-27 21:04:07 +08:00
const SizedBox(height: 4),
GestureDetector(
2026-02-27 21:04:07 +08:00
onTap: () => _copyToClipboard(deviceId, '设备ID已复制到剪贴板'),
child: const Icon(
Icons.copy,
size: 16,
color: Color(0xFF999999),
),
),
],
),
),
],
),
);
}
2026-02-27 21:04:07 +08:00
/// 资源中心卡片(保持不变)
Widget _buildResourceCenterCard() {
return Container(
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
2026-02-27 21:04:07 +08:00
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.1),
blurRadius: 8,
offset: const Offset(0, 2),
),
],
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(bottom: 16),
child: Text(
'资源中心',
style: TextStyle(fontSize: 14, color: Color(0xFF999999)),
),
),
_buildResourceItem('使用说明', Icons.description_outlined),
const Divider(height: 32, color: Color(0xFFF0F0F0)),
_buildResourceItem('产品手册', Icons.book_outlined),
],
),
);
}
2026-02-27 21:04:07 +08:00
/// 通用信息行组件(保持不变)
Widget _buildInfoRow({
2026-02-27 21:04:07 +08:00
required BuildContext context,
required IconData icon,
required String label,
required Widget trailing,
}) {
return Row(
children: [
Icon(icon, size: 18, color: const Color(0xFF999999)),
const SizedBox(width: 12),
Text(label, style: const TextStyle(fontSize: 16)),
const Spacer(),
trailing,
],
);
}
2026-02-27 21:04:07 +08:00
/// 资源项组件(保持不变)
Widget _buildResourceItem(String title, IconData icon) {
2026-02-27 21:04:07 +08:00
return InkWell(
onTap: () {
ScaffoldMessenger.of(
context,
).showSnackBar(SnackBar(content: Text('暂未开放$title功能')));
},
child: Row(
children: [
Icon(icon, size: 18, color: const Color(0xFF007AFF)),
const SizedBox(width: 12),
Text(title, style: const TextStyle(fontSize: 16)),
const Spacer(),
const Icon(
Icons.arrow_forward_ios,
size: 16,
color: Color(0xFF999999),
),
],
),
);
}
2026-02-27 21:04:07 +08:00
/// 解绑设备按钮(保持不变)
Widget _buildUnbindButton(BuildContext context) {
return SizedBox(
width: double.infinity,
2026-02-27 21:04:07 +08:00
height: 50,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
foregroundColor: const Color(0xFFFF3B30),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
2026-02-27 21:04:07 +08:00
side: const BorderSide(color: Color(0xFFFF3B30), width: 1),
padding: const EdgeInsets.symmetric(vertical: 8),
textStyle: const TextStyle(height: 1.2),
),
2026-02-27 21:04:07 +08:00
onPressed: _isUpdatingName ? null : () => _showUnbindConfirmDialog(),
child: const Row(
mainAxisAlignment: MainAxisAlignment.center,
2026-02-27 21:04:07 +08:00
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(Icons.unarchive_outlined, size: 18),
2026-02-27 21:04:07 +08:00
SizedBox(width: 8),
Text(
'解绑设备',
style: TextStyle(fontSize: 16, height: 1.0),
overflow: TextOverflow.visible,
),
],
),
),
);
}
2026-02-27 21:04:07 +08:00
/// 显示解绑确认弹窗(保持不变)
void _showUnbindConfirmDialog() {
showDialog(
context: context,
builder: (dialogContext) {
_dialogContext = dialogContext;
return AlertDialog(
title: const Text('确认解绑'),
content: Text('确定要解绑【$_deviceName】吗?解绑后将无法管理该设备'),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext),
child: const Text('取消'),
),
TextButton(
style: TextButton.styleFrom(
foregroundColor: const Color(0xFFFF3B30),
),
onPressed: _executeUnbind,
child: const Text('确认'),
),
],
);
},
);
}
2026-02-27 14:16:29 +08:00
Future<void> _executeUnbind() async {
if (_deviceId.isEmpty || _deviceName.isEmpty) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("设备信息异常,无法解绑"),
backgroundColor: Colors.red,
),
);
}
return;
}
2026-02-27 21:04:07 +08:00
// 关闭确认弹窗
2026-02-27 14:16:29 +08:00
if (_dialogContext != null && Navigator.canPop(_dialogContext!)) {
Navigator.pop(_dialogContext!);
}
2026-02-27 21:04:07 +08:00
try {
// 显示加载弹窗并记录上下文
if (context.mounted) {
showDialog(
context: context,
barrierDismissible: false,
builder: (ctx) {
_loadingDialogContext = ctx;
return const AlertDialog(
content: Row(
children: [
CircularProgressIndicator(strokeWidth: 2),
SizedBox(width: 16),
Text("正在解绑设备..."),
],
),
);
},
);
}
// 调用Cubit解绑方法
await context.read<DevicesCubit>().unbindDevice(_deviceId, _deviceName);
// 主动关闭加载弹窗
if (_loadingDialogContext != null &&
Navigator.canPop(_loadingDialogContext!)) {
Navigator.pop(_loadingDialogContext!);
_loadingDialogContext = null;
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("解绑异常:${e.toString()}"),
backgroundColor: Colors.red,
2026-02-27 14:16:29 +08:00
),
2026-02-27 21:04:07 +08:00
);
// 关闭加载弹窗
if (_loadingDialogContext != null &&
Navigator.canPop(_loadingDialogContext!)) {
Navigator.pop(_loadingDialogContext!);
_loadingDialogContext = null;
}
}
}
}
/// 执行修改设备名称(核心修改:新增兜底逻辑)
Future<void> _executeUpdateDeviceName(String newDeviceName) async {
// 基础校验
if (_deviceId.isEmpty || newDeviceName.isEmpty) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("设备信息异常,无法修改名称"),
backgroundColor: Colors.red,
),
);
}
setState(() => _isUpdatingName = false);
2026-02-27 14:16:29 +08:00
return;
}
2026-02-27 21:04:07 +08:00
try {
// 显示加载弹窗并记录专属上下文
if (context.mounted) {
showDialog(
context: context,
barrierDismissible: false,
builder: (ctx) {
_updateLoadingContext = ctx;
return const AlertDialog(
content: Row(
children: [
CircularProgressIndicator(strokeWidth: 2),
SizedBox(width: 16),
Text("正在修改名称..."),
],
),
);
},
);
}
print(
"调用updateDeviceName,deviceId: $_deviceId, newDeviceName: $newDeviceName",
2026-02-27 14:16:29 +08:00
);
2026-02-27 21:04:07 +08:00
// 调用Cubit修改方法
await context.read<DevicesCubit>().updateDeviceName(
_deviceId,
newDeviceName,
);
// 主动关闭修改名称加载弹窗
if (_updateLoadingContext != null &&
Navigator.canPop(_updateLoadingContext!)) {
Navigator.pop(_updateLoadingContext!);
_updateLoadingContext = null;
}
// 主动重置更新状态
setState(() => _isUpdatingName = false);
2026-02-27 14:16:29 +08:00
2026-02-27 21:04:07 +08:00
// 兜底:强制将Cubit的isLoading置为false
if (context.mounted) {
context.read<DevicesCubit>().emit(
context.read<DevicesCubit>().state.copyWith(
isLoading: false,
operationType: DeviceOperationType.none,
),
);
}
} catch (e) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("修改异常:${e.toString()}"),
backgroundColor: Colors.red,
),
);
// 关闭修改名称加载弹窗
if (_updateLoadingContext != null &&
Navigator.canPop(_updateLoadingContext!)) {
Navigator.pop(_updateLoadingContext!);
_updateLoadingContext = null;
2026-02-27 14:16:29 +08:00
}
2026-02-27 21:04:07 +08:00
}
setState(() => _isUpdatingName = false);
// 兜底:强制重置Cubit的loading状态
if (context.mounted) {
context.read<DevicesCubit>().emit(
context.read<DevicesCubit>().state.copyWith(
isLoading: false,
operationType: DeviceOperationType.none,
),
);
}
}
}
/// 处理解绑结果(保持不变)
void _handleUnbindResult(DevicesState state) {
// 强制关闭加载弹窗
if (_loadingDialogContext != null &&
Navigator.canPop(_loadingDialogContext!)) {
Navigator.pop(_loadingDialogContext!);
_loadingDialogContext = null;
} else if (!state.isLoading &&
context.mounted &&
Navigator.canPop(context)) {
Navigator.pop(context);
}
if (state.errorMessage?.isEmpty == true && !state.isLoading) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("设备「$_deviceName」解绑成功"),
backgroundColor: Colors.green,
duration: const Duration(seconds: 2),
),
);
final username =
context.read<AppUserCubit>().state.user?.username ?? "";
context.read<DevicesCubit>().fetchAllDevices(username);
}
} else if (state.errorMessage?.isNotEmpty == true && !state.isLoading) {
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("解绑失败:${state.errorMessage ?? '未知错误'}"),
backgroundColor: Colors.red,
),
);
}
}
context.go(RoutePaths.home);
}
/// 处理修改名称结果(核心修改:放宽判断条件)
void _handleUpdateNameResult(DevicesState state) {
// 强制关闭修改名称加载弹窗(优先用专属上下文)
if (_updateLoadingContext != null &&
Navigator.canPop(_updateLoadingContext!)) {
Navigator.pop(_updateLoadingContext!);
_updateLoadingContext = null;
}
// 兜底:兼容旧逻辑
else if (context.mounted && Navigator.canPop(context)) {
// 不管loading状态,只要弹窗存在就关闭
Navigator.pop(context);
}
// 处理结果:放宽条件,只要无错误信息就认为成功(不管loading)
print(
"处理修改名称结果,operationType: ${state.operationType}, isLoading: ${state.isLoading}, errorMessage: ${state.errorMessage},state.errorMessage?.isEmpty: ${state.errorMessage?.isEmpty}",
);
// 核心修改:去掉!state.isLoading的判断
if (state.errorMessage?.isEmpty == true) {
setState(() {
_deviceName = _nameController.text.trim();
_isUpdatingName = false; // 双重保障重置状态
2026-02-27 14:16:29 +08:00
});
2026-02-27 21:04:07 +08:00
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("设备名称已修改为:$_deviceName"),
backgroundColor: Colors.green,
duration: const Duration(seconds: 2),
),
);
// 关闭修改名称的底部抽屉(如果还在)
if (_editNameSheetContext != null &&
Navigator.canPop(_editNameSheetContext!)) {
Navigator.pop(_editNameSheetContext!);
_editNameSheetContext = null;
}
// 强制重置Cubit的loading状态
context.read<DevicesCubit>().emit(
state.copyWith(
isLoading: false,
operationType: DeviceOperationType.none,
),
);
}
2026-02-27 14:16:29 +08:00
} else if (state.errorMessage?.isNotEmpty == true) {
2026-02-27 21:04:07 +08:00
setState(() => _isUpdatingName = false);
if (context.mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text("修改失败:${state.errorMessage ?? '未知错误'}"),
backgroundColor: Colors.red,
),
);
// 强制重置Cubit的loading状态
context.read<DevicesCubit>().emit(
state.copyWith(
isLoading: false,
operationType: DeviceOperationType.none,
),
);
}
}
}
/// 复制到剪贴板(保持不变)
void _copyToClipboard(String text, String tip) {
Clipboard.setData(ClipboardData(text: text));
if (context.mounted) {
2026-02-27 14:16:29 +08:00
ScaffoldMessenger.of(context).showSnackBar(
2026-02-27 21:04:07 +08:00
SnackBar(content: Text(tip), duration: const Duration(seconds: 1)),
2026-02-27 14:16:29 +08:00
);
}
}
}