From 5c5234516c15eb442edc3462c60189015b41878a Mon Sep 17 00:00:00 2001 From: MiaoMint <1981324730@qq.com> Date: Fri, 4 Aug 2023 21:09:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=9A=84=E7=81=B0?= =?UTF-8?q?=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/home/widgets/home_resent_card.dart | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/pages/home/widgets/home_resent_card.dart b/lib/pages/home/widgets/home_resent_card.dart index 606b5dea..6c362943 100644 --- a/lib/pages/home/widgets/home_resent_card.dart +++ b/lib/pages/home/widgets/home_resent_card.dart @@ -26,12 +26,17 @@ class _HomeRecentCardState extends State { late ExtensionRuntime? _runtime; String _update = ""; - PaletteGenerator? _paletteGenerator; + // 主要颜色 + Color? primaryColor; @override void initState() { _getUpdate(); - _genColor(); + + if (widget.history.type != ExtensionType.bangumi) { + _genColor(); + } + super.initState(); } @@ -50,11 +55,13 @@ class _HomeRecentCardState extends State { if (widget.history.type == ExtensionType.bangumi) { return; } - _paletteGenerator = await PaletteGenerator.fromImageProvider( + final paletteGenerator = await PaletteGenerator.fromImageProvider( CachedNetworkImageProvider(widget.history.cover), maximumColorCount: 2, ); + primaryColor = paletteGenerator.colors.firstOrNull; + if (mounted) { setState(() {}); } @@ -140,9 +147,9 @@ class _HomeRecentCardState extends State { image: DecorationImage( image: CachedNetworkImageProvider(widget.history.cover), fit: BoxFit.cover, - colorFilter: _paletteGenerator != null + colorFilter: primaryColor != null ? ColorFilter.mode( - _paletteGenerator!.colors.first.withOpacity(0.9), + primaryColor!.withOpacity(0.9), BlendMode.srcOver, ) : null,