Debug School

rakesh kumar
rakesh kumar

Posted on

How to add substring range if the word is less than the range in Flutter

Task
Image description

Solution

var text = 'simply dummy text for printing ';
Text(text.length > 12 ? text.substring(0, 12) : text,),
Enter fullscreen mode Exit fullscreen mode
 child: Text(
                          widget.data.length > 12?widget.data.substring(0, 12)+ "..":widget.data,
                          style: TextStyle(
                              fontSize: displayWidth(context) * 0.070,                            
                              color: Colors.black,                            
                              fontWeight: FontWeight.bold),
                        ),
Enter fullscreen mode Exit fullscreen mode

Image description
clik here for Refrence

Top comments (0)