Skip to content

Instantly share code, notes, and snippets.

@amirul12
Created December 3, 2022 06:01
Show Gist options
  • Save amirul12/995cc30bab7ece1f1908e6b2b0d3d923 to your computer and use it in GitHub Desktop.
Save amirul12/995cc30bab7ece1f1908e6b2b0d3d923 to your computer and use it in GitHub Desktop.
Text with bellow dot
import 'package:flutter/material.dart';
class SizedText extends StatelessWidget {
final String text;
final Color color;
const SizedText({Key? key, required this.text,required this.color}) : super(key: key);
@override
Widget build(BuildContext context) {
final Size textSize= _textSize(text);
return Container(
child: Column(
children: [
Text(
text,
style:TextStyle(
fontSize: 16,
color:color,
fontWeight: FontWeight.w700
),
maxLines: 1,
softWrap: false,
overflow: TextOverflow.clip,
),
SizedBox(height: 5),
Row(
children: [
for(int i=0; i<textSize.width/5;i++)
i.isEven?Container(
width: 5,
color: color,
height: 2,
):Container(
width: 5,
color: Colors.white,
height: 2,
)
],
),
],
),
);
}
Size _textSize(String text)
{
final TextPainter textPainter=TextPainter(
text:TextSpan(text: text,style:TextStyle(
fontSize: 16,
color:color,
fontWeight: FontWeight.w700
)),
maxLines: 1,
textDirection: TextDirection.ltr
)..layout(minWidth: 0,maxWidth: double.infinity);
return textPainter.size;
}
}
@amirul12
Copy link
Author

amirul12 commented Dec 3, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment