使用 assets_util 来管理 assets
This commit is contained in:
@@ -6,6 +6,7 @@ import '../screens/part_screen.dart';
|
||||
import 'floating_icon_with_wave.dart';
|
||||
import 'dart:async';
|
||||
import 'package:basic_intl/intl.dart';
|
||||
import '../utils/assets_util.dart';
|
||||
|
||||
class FloatingIcon extends StatefulWidget {
|
||||
const FloatingIcon({super.key});
|
||||
@@ -35,13 +36,13 @@ class _FloatingIconState extends State<FloatingIcon> with TickerProviderStateMix
|
||||
// 图片切换相关
|
||||
int _imageIndex = 0;
|
||||
late final List<String> _iconImages = [
|
||||
'assets/images/ai1_hd.png',
|
||||
'assets/images/ai0_hd.png',
|
||||
'ai1_hd.png',
|
||||
'ai0_hd.png',
|
||||
];
|
||||
|
||||
late final List<String> _iconImagesEn = [
|
||||
'assets/images/ai1_hd_en.png',
|
||||
'assets/images/ai0_hd_en.png',
|
||||
'ai1_hd_en.png',
|
||||
'ai0_hd_en.png',
|
||||
];
|
||||
|
||||
@override
|
||||
@@ -96,7 +97,7 @@ class _FloatingIconState extends State<FloatingIcon> with TickerProviderStateMix
|
||||
// 显示全屏界面
|
||||
void _showFullScreen() async {
|
||||
_hidePartScreen();
|
||||
final messageService = context.read<MessageService>();
|
||||
final messageService = MessageService.instance;
|
||||
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
@@ -170,7 +171,10 @@ class _FloatingIconState extends State<FloatingIcon> with TickerProviderStateMix
|
||||
// }
|
||||
// });
|
||||
|
||||
return ChangeNotifierProvider(create: (_) => MessageService(), child: _buildFloatingIcon());
|
||||
return ChangeNotifierProvider.value(
|
||||
value: MessageService.instance,
|
||||
child: _buildFloatingIcon(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildFloatingIcon() {
|
||||
@@ -249,13 +253,12 @@ class _FloatingIconState extends State<FloatingIcon> with TickerProviderStateMix
|
||||
iconSize: iconSize,
|
||||
waveColor: Colors.white,
|
||||
)
|
||||
: Image.asset(
|
||||
: AssetsUtil.getImageWidget(
|
||||
Intl.getCurrentLocale().startsWith('zh')
|
||||
? _iconImages[_imageIndex]
|
||||
: _iconImagesEn[_imageIndex],
|
||||
width: iconSize,
|
||||
height: iconSize,
|
||||
package: 'ai_chat_assistant',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user