size_tailored_text 1.0.5 size_tailored_text: ^1.0.5 copied to clipboard
This text widget automatically adjusts the font size to prevent overflow error messages by ensuring it does not exceed the given space.
import 'package:flutter/material.dart';
import 'package:size_tailored_text/size_tailored_text.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
const text =
'안녕하세요.dfdsafdsafsd dsff next time.\nplugin example app test Nice Weather in Earth. 입니다!';
const style = TextStyle(
fontSize: 50,
overflow: TextOverflow.fade,
color: Colors.black,
fontWeight: FontWeight.w800,
);
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: const SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizeTailoredTextWidget(
text,
width: 200,
height: 200,
maxLines: 5,
minFontSize: 1,
textAlign: TextAlign.left,
style: style,
),
SizedBox(
width: 200,
height: 200,
child: Text(
text,
maxLines: 5,
textAlign: TextAlign.left,
style: style,
),
)
],
),
),
),
);
}
}