How To Easily Align Flutter Text Justify

Flutter text justify

In this Flutter post, we will see how to properly align and set Flutter text justify in our Flutter app using a proper Flutter example code. We will be following a step by step approach to explain each and everything about Flutter text justify and so you can easily implement it in your own Flutter app as well. So why wait more, let’s get right into implementing Flutter text justify in our Flutter text widget.

What is Flutter Text Justify?

Flutter text justify as the name suggests, it is the process of replacing the default text alignment with justify. We will first see what the default Flutter text widget alignment is and then we will convert it to Flutter text justify by the use of a simple Flutter example.

Default Flutter Text Alignment

To see the default alignment of Flutter text, we have to define a simple Flutter text widget with a text. As the text will be made long so we can easily see its default alignment. We have removed some text to avoid bulkiness of code. See the below given code:

Text(
   'This is the default Flutter alignment...This is the default Flutter alignment.')
Flutter text default alignment
This is the default Flutter text alignment which can seen in the above given image.

Implementing Flutter Text Justify

Now let’ get into making the Flutter text alignment to justify. For that, you have to use the text align constructor of the Flutter text widget class and pass TextAlign.justify to it. I have removed some text to avoid bulkiness of code. See the below code:

Text(
    'This is the justified Flutter alignment...This is the justified Flutter alignment.',
    textAlign: TextAlign.justify
      )
Flutter text justify
The Flutter text justify has been implemented successfully and can be seen in the above image.
So this is how you can easily implement Flutter text justify in your own Flutter apps with ease. Let me know if you still face any issues regarding Flutter text justify. I would love to clear your queries.
Below is the complete source code of the above implemented Flutter text justify.

Flutter Text Justify Implementation Source Code

Flutter text justify

import 'package:flutter/material.dart';
void main() {
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Homepage(),
    );
  }
}
class Homepage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SafeArea(
        child: Scaffold(
            body: Center(
                child: Padding(
      padding: const EdgeInsets.all(15),
      child: Text(
        'This is the justified Flutter alignment. This is the justified Flutter alignment. This is the justified Flutter alignment. This is the justified Flutter alignment.',
        textAlign: TextAlign.justify,
      ),
    ))));
  }
}

Conclusion

As a conclusion of this post, now you have an in-depth and complete implementation understanding of how to use Flutter text justify. Don’t hold back on your honest feedback regarding the post. Thank you for reading this post.

Leave a Comment

Your email address will not be published.