Skip to content

Commit

Permalink
update 1.0.4
Browse files Browse the repository at this point in the history
개행문이 포함된 text에 maxLines가 1로 설정되었다면 text의 개행문을 공백으로 변경하여 한줄에 표현될 수 있도록 수정
  • Loading branch information
aqoong committed Aug 31, 2024
1 parent 4f411ee commit 3795a23
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,8 @@ pre-release version

## 1.0.3

* Expand and release the supported platforms for reasons that do not use the Platform SDK.
* Expand and release the supported platforms for reasons that do not use the Platform SDK.

## 1.0.4

* Modified to replace all newline characters (\n) with spaces in the text when maxLines is set to 1, ensuring the text is displayed on a single line.
4 changes: 2 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class _MyAppState extends State<MyApp> {

@override
Widget build(BuildContext context) {
const text = '안녕하세요.dfdsafdsafsd dsff next time. plugin example app test Nice Weather in Earth. 입니다!';
const text = '안녕하세요.dfdsafdsafsd dsff next time.\nplugin example app test Nice Weather in Earth. 입니다!';
const style = TextStyle(
fontSize: 100,
fontSize: 50,
overflow: TextOverflow.fade,
color: Colors.black,
fontWeight: FontWeight.w800,
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.2"
version: "1.0.4"
sky_engine:
dependency: transitive
description: flutter
Expand Down
12 changes: 8 additions & 4 deletions lib/size_tailored_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SizeTailoredText extends StatelessWidget {

const SizeTailoredText(
this.text, {
Key? key,
super.key,
this.width,
this.height,
this.style,
Expand All @@ -49,11 +49,15 @@ class SizeTailoredText extends StatelessWidget {
this.textHeightBehavior,
this.minFontSize = 8,
this.stepGranularity = 0.5,
}) : assert(maxLines > 0, 'maxLines must be greater than 0'),
super(key: key);
}) : assert(maxLines > 0, 'maxLines must be greater than 0');

@override
Widget build(BuildContext context) {
String clearedText = text;
if (maxLines == 1 && text.contains('\n')) {
clearedText = text.replaceAll('\n', ' ');
}

return LayoutBuilder(builder: (context, constraints) {
final maxWidth = width ?? constraints.maxWidth;
final maxHeight = height ?? constraints.maxHeight;
Expand All @@ -65,7 +69,7 @@ class SizeTailoredText extends StatelessWidget {
while (fontSize - stepGranularity >= minFontSize) {
tempTextSpan = TextSpan(
children: _buildTextSpans(
text: text,
text: clearedText,
style: effectiveStyle.copyWith(fontSize: fontSize),
maxWidth: maxWidth),
);
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: size_tailored_text
description: "This text widget automatically adjusts the font size to prevent overflow error messages by ensuring it does not exceed the given space."
version: 1.0.3
version: 1.0.4
homepage: https://github.com/aqoong/size_tailored_text

environment:
Expand Down

0 comments on commit 3795a23

Please sign in to comment.