开始给原先适配期的状态擦屁股:现在是修复播放页与播放列表页的显示

This commit is contained in:
2026-09-02 20:44:46 +08:00
parent 200067a3b2
commit cdf77b308d
4 changed files with 76 additions and 64 deletions
+5 -6
View File
@@ -2,6 +2,7 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../services/audio_service.dart';
import '../utils/navigation.dart'; // ⭐ 导入 navigatorKey
class GlobalMiniPlayer extends StatelessWidget {
const GlobalMiniPlayer({super.key});
@@ -45,11 +46,9 @@ class GlobalMiniPlayer extends StatelessWidget {
color: Colors.transparent,
child: InkWell(
onTap: () {
// ⭐ 使用 Navigator.of(context) 替代 navigatorKey
Navigator.of(context, rootNavigator: true)
.pushNamed('/player');
// ⭐ 使用 navigatorKey 直接跳转
navigatorKey.currentState?.pushNamed('/player');
},
// ⭐ 替换弃用的 withOpacity 为 withValues
highlightColor: Colors.white.withValues(alpha: 0.05),
splashColor: Colors.white.withValues(alpha: 0.1),
borderRadius: BorderRadius.circular(12),
@@ -124,8 +123,8 @@ class GlobalMiniPlayer extends StatelessWidget {
size: 24,
),
onPressed: () {
// ⭐ 使用 Navigator.of(context)
Navigator.of(context).pushNamed('/playlist');
// ⭐ 使用 navigatorKey 直接跳转
navigatorKey.currentState?.pushNamed('/playlist');
},
),
const SizedBox(width: 4),