To make the text to the center of the AppBar
instead of the top of the AppBar
.
To align the text lower a bit
appBar: AppBar(
backgroundColor: Colors.white,
title: const Text("Test", style:TextStyle(color: Colors.black)),
actions: [Text( formattedDate, style:TextStyle(color: Colors.black))
],
),
2
Answers
Wrap the
Text
widget with anAlign
widget like this:To align the text in the actions of your AppBar in Flutter, you can wrap the Text widget with a Container and use the alignment property to control the alignment. Here’s an example of how to do it:
In the code above, the Container is used to wrap the Text widget within the actions list of the AppBar, and the alignment property of the Container is set to Alignment.center to horizontally center-align the text. You can adjust the alignment by using other values from the Alignment class as needed.