Skip to main content

Flutter Set Spacing Between Text Words using wordSpacing

Flutter comes with a unique text property wordSpacing. Word Spacing is adding extra space(given in pixels) at the each end of empty white space between words in text also at the end of text. This property supports value in Double format. So in today's article we would learn about Flutter Set Spacing Between Text Words using wordSpacing.

Flutter Set Spacing Between Text Words using wordSpacing:

1. Open your project's main.dart file and create text widget with word spacing.
Text(
        'This is a Demo Text for wordSpacing in Flutter.',
        style: TextStyle(wordSpacing: 7.0),
      )
2. To show you the difference between word spacing applied text and without word spacing text, I am sharing both app screenshots below.
Screenshot With wordSpacing Text:
Flutter Set Spacing Between Text Words using wordSpacing
Screenshot Without wordSpacing text:
Without Word Spacing applied text in flutter
3. 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(
        'This is a Demo Text for wordSpacing in Flutter.',
        style: TextStyle(wordSpacing: 7.0),
      ))),
    );
  }
}

Comments