From 55e5a19af5927c49b497f0983fabae88b0c8c07b Mon Sep 17 00:00:00 2001 From: Kabo <20254485+kaboc@users.noreply.github.com> Date: Sat, 23 Sep 2023 20:14:47 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=B0=E3=83=A9=E3=83=87=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE=E5=87=A6=E7=90=86=E3=81=AE?= =?UTF-8?q?=E3=82=B7=E3=83=B3=E3=83=97=E3=83=AB=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/components/section_header.dart | 45 +++++++------------------ 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/lib/core/components/section_header.dart b/lib/core/components/section_header.dart index 6edee463..40cca2e0 100644 --- a/lib/core/components/section_header.dart +++ b/lib/core/components/section_header.dart @@ -30,22 +30,19 @@ final class SectionHeader extends StatelessWidget { @override Widget build(BuildContext context) { - final component = ShaderMask( - shaderCallback: (Rect bounds) { - // NOTE: bounds から取得するとグラデーションが想定どおりかからないため、テキストサイズを別途取得する - final textSize = _getTextSize(maxWidth: bounds.width); - return gradient.createShader( - Rect.fromLTWH(0, 0, textSize.width, textSize.height), - ); - }, - blendMode: BlendMode.srcIn, - child: Padding( - // NOTE: Text Widget の描画範囲から外れて文字やブラーが見切れてしまうため、現状は左右に余白を設けている - padding: const EdgeInsets.all(_blurRadius), - child: Text( - text, - style: style.copyWith( - color: Colors.white, + final component = Align( + alignment: Alignment.centerLeft, + child: ShaderMask( + shaderCallback: gradient.createShader, + blendMode: BlendMode.srcIn, + child: Padding( + // NOTE: Text Widget の描画範囲から外れて文字やブラーが見切れてしまうため、現状は左右に余白を設けている + padding: const EdgeInsets.all(_blurRadius), + child: Text( + text, + style: style.copyWith( + color: Colors.white, + ), ), ), ), @@ -61,20 +58,4 @@ final class SectionHeader extends StatelessWidget { return component; } - - /// 描画するテキストのサイズを取得する - Size _getTextSize({ - required double maxWidth, - }) { - final textPainter = TextPainter( - text: TextSpan( - text: text, - style: style, - ), - textDirection: TextDirection.ltr, - )..layout( - maxWidth: maxWidth, - ); - return textPainter.size; - } } From 39f47d1adb16ff8c65b780feddf06d07025fdfeb Mon Sep 17 00:00:00 2001 From: Kabo <20254485+kaboc@users.noreply.github.com> Date: Sat, 23 Sep 2023 21:32:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=91=E3=83=95=E3=82=A9=E3=83=BC?= =?UTF-8?q?=E3=83=9E=E3=83=B3=E3=82=B9=E3=82=92=E6=94=B9=E5=96=84=EF=BC=88?= =?UTF-8?q?=E4=B8=BB=E3=81=ABiOS=E3=81=A7=E3=81=AE=E9=87=8D=E3=81=95?= =?UTF-8?q?=E3=81=AE=E8=A7=A3=E6=B6=88=E3=81=AE=E3=81=9F=E3=82=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/core/components/section_header.dart | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/core/components/section_header.dart b/lib/core/components/section_header.dart index 40cca2e0..e6821e1c 100644 --- a/lib/core/components/section_header.dart +++ b/lib/core/components/section_header.dart @@ -32,16 +32,18 @@ final class SectionHeader extends StatelessWidget { Widget build(BuildContext context) { final component = Align( alignment: Alignment.centerLeft, - child: ShaderMask( - shaderCallback: gradient.createShader, - blendMode: BlendMode.srcIn, - child: Padding( - // NOTE: Text Widget の描画範囲から外れて文字やブラーが見切れてしまうため、現状は左右に余白を設けている - padding: const EdgeInsets.all(_blurRadius), - child: Text( - text, - style: style.copyWith( - color: Colors.white, + child: RepaintBoundary( + child: ShaderMask( + shaderCallback: gradient.createShader, + blendMode: BlendMode.srcIn, + child: Padding( + // NOTE: Text Widget の描画範囲から外れて文字やブラーが見切れてしまうため、現状は左右に余白を設けている + padding: const EdgeInsets.all(_blurRadius), + child: Text( + text, + style: style.copyWith( + color: Colors.white, + ), ), ), ),