Created
December 3, 2022 06:01
-
-
Save amirul12/995cc30bab7ece1f1908e6b2b0d3d923 to your computer and use it in GitHub Desktop.
Text with bellow dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/HaseebImd/Payment-App-UI-Flutter