In flutter to set text line height we would use height property of Text Style. It support double integer value. The value given in height property is by default multiplied by text font size. See the below example for more details.
Flutter Set Text Line Height | Line Vertical Spacing:
1. Defining Text widget with height spacing.
Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s',
style: TextStyle(height: 2.00),
)
Here in the given example I have given height value as 2.00 which represents 200% line height as per default line height.
Screenshot with applying line height:
2. Complete source code for main.dart file:
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Center(
child: Text(
'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s',
style: TextStyle(height: 2.00),
))),
);
}
}
Comments
Post a Comment