In our Flutter code, you can use the Padding widget:
Example 1
Padding(
padding: EdgeInsets.all(10.0),
child: Text("Hello, Doripot!”),
)
Example 2
//-Use this widget as per the eenter of the screen
Center(
child: Padding(
padding: EdgeInsets.all(16.0),
// Adjust the padding values as per your needed
child: Text(
'Hello, Doripot!',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 20.0,
fontFamily: 'Poppins',
fontWeight: FontWeight.w500,
),
),
),
),
Example 3
Center(
child: Padding(
padding: EdgeInsets.all(16.0),
// Adjust the padding values as per your needed
child: Text(
'Hello, Doripot!',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 20.0,
fontFamily: 'Poppins',
color: Colors.red,
fontWeight: FontWeight.w500,
),
),
),
),
SizedBox(
height: 10,
),
Center(
child: Padding(
padding: EdgeInsets.only(
left: 16.0, right: 16.0, top: 16.0, bottom: 16.0),
// Adjust the padding values as per your needed
child: Text(
'This is left,right,top,bottom 16.0 Adjust on your screen',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 20.0,
fontFamily: 'Poppins',
color: Colors.red,
fontWeight: FontWeight.w500,
),
),
),
),
Center(
child: Padding(
padding: EdgeInsets.only(
left: 16.0,),
// Adjust the padding values as per your needed
child: Text(
'Only left side 16',
overflow: TextOverflow.ellipsis,
textAlign: TextAlign.left,
style: TextStyle(
fontSize: 20.0,
fontFamily: 'Poppins',
color: Colors.red,
fontWeight: FontWeight.w500,
),
),
),
),
Output
In this example, the Padding widget is used with the EdgeInsets.all(16.0) to provide padding on all sides of the Text widget. You can adjust the padding values according to your design requirements. The TextStyle parameter is optional and allows you to customize the text style, such as font size, color, etc. on your screen.