diff --git a/CHANGELOG.md b/CHANGELOG.md index f3ec164..6760075 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## [next] +* fix: Update vertical alignment ([#19](https://github.com/bdlukaa/rounded_background_text/issues/19)) * breaking: Remove `textScaleFactor`. Use `textScaler` instead * feat: Add missing fields to `RoundedBackgroundTextField` * Added `textHeightBehavior` diff --git a/lib/src/rounded_background_text.dart b/lib/src/rounded_background_text.dart index 744d707..553ac3e 100644 --- a/lib/src/rounded_background_text.dart +++ b/lib/src/rounded_background_text.dart @@ -154,6 +154,7 @@ class RoundedBackgroundText extends StatelessWidget { innerRadius: innerRadius, outerRadius: outerRadius, backgroundColor: backgroundColor, + textWidthBasis: textWidthBasis, ), SelectableText.rich( textSpan, @@ -171,6 +172,7 @@ class RoundedBackgroundText extends StatelessWidget { autofocus: autofocus, semanticsLabel: semanticsLabel, magnifierConfiguration: magnifierConfiguration, + textWidthBasis: textWidthBasis, ), ]); } @@ -656,19 +658,19 @@ class LineMetricsHelper { left: height * _horizontalPaddingFactor, right: height * _horizontalPaddingFactor, top: height * 0.3, - bottom: 0, + bottom: height * 0.175 / 2, ); late final EdgeInsets _innerLinePadding = EdgeInsets.only( left: height * _horizontalPaddingFactor, right: height * _horizontalPaddingFactor, top: 0.0, - bottom: height * 0.175, + bottom: height * 0.175 / 2, ); late final EdgeInsets _lastLinePadding = EdgeInsets.only( left: height * _horizontalPaddingFactor, right: height * _horizontalPaddingFactor, top: 0.0, - bottom: height * 0.175, + bottom: height * 0.175 / 2, ); /// Dynamically calculate the outer factor based on the provided [outerRadius] diff --git a/lib/src/rounded_background_text_field.dart b/lib/src/rounded_background_text_field.dart index 3f5fe38..41adca8 100644 --- a/lib/src/rounded_background_text_field.dart +++ b/lib/src/rounded_background_text_field.dart @@ -511,21 +511,13 @@ class _RoundedBackgroundTextFieldState ); return Stack( - alignment: () { - switch (widget.textAlign) { - case TextAlign.end: - return AlignmentDirectional.topEnd; - case TextAlign.start: - return AlignmentDirectional.topStart; - case TextAlign.left: - return Alignment.topLeft; - case TextAlign.right: - return Alignment.topRight; - case TextAlign.center: - default: - return Alignment.topCenter; - } - }(), + alignment: switch (widget.textAlign) { + TextAlign.end => AlignmentDirectional.topEnd, + TextAlign.start => AlignmentDirectional.topStart, + TextAlign.left => Alignment.topLeft, + TextAlign.right => Alignment.topRight, + TextAlign.center || _ => Alignment.topCenter, + }, children: [ if (textController.text.isNotEmpty) Positioned(